1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-10 07:53:58 +02:00

Rename methods

SizeInterface::getWidth to SizeInterface::width
SizeInterface::getHeight to SizeInterface::height
This commit is contained in:
Oliver Vogel
2023-10-24 20:07:30 +02:00
parent 9150e4bfa3
commit 826fd22f4f
28 changed files with 211 additions and 211 deletions

View File

@@ -116,11 +116,11 @@ abstract class AbstractFont implements FontInterface
public function capHeight(): int public function capHeight(): int
{ {
return $this->getBoxSize('T')->getHeight(); return $this->getBoxSize('T')->height();
} }
public function fontSizeInPixels(): int public function fontSizeInPixels(): int
{ {
return $this->getBoxSize('Hy')->getHeight(); return $this->getBoxSize('Hy')->height();
} }
} }

View File

@@ -22,8 +22,8 @@ abstract class AbstractFitModifier
$crop = new Rectangle($this->width, $this->height); $crop = new Rectangle($this->width, $this->height);
$crop = $crop->contain( $crop = $crop->contain(
$imagesize->getWidth(), $imagesize->width(),
$imagesize->getHeight() $imagesize->height()
)->alignPivotTo($imagesize, $this->position); )->alignPivotTo($imagesize, $this->position);
return $crop; return $crop;

View File

@@ -37,8 +37,8 @@ class CropModifier implements ModifierInterface
{ {
// create new image // create new image
$modified = imagecreatetruecolor( $modified = imagecreatetruecolor(
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight() $resizeTo->height()
); );
// get current image // get current image
@@ -64,18 +64,18 @@ class CropModifier implements ModifierInterface
0, 0,
$resizeTo->getPivot()->getX() + $this->offset_x, $resizeTo->getPivot()->getX() + $this->offset_x,
$resizeTo->getPivot()->getY() + $this->offset_y, $resizeTo->getPivot()->getY() + $this->offset_y,
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight(), $resizeTo->height(),
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight(), $resizeTo->height(),
); );
imagedestroy($current); imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex); imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resizeTo->getHeight(); ++$y) { for ($y = 0; $y < $resizeTo->height(); ++$y) {
for ($x = 0; $x < $resizeTo->getWidth(); ++$x) { for ($x = 0; $x < $resizeTo->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) { if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel( imagesetpixel(
$modified, $modified,

View File

@@ -50,8 +50,8 @@ class FillModifier implements ModifierInterface
$frame->getCore(), $frame->getCore(),
0, 0,
0, 0,
$frame->getSize()->getWidth() - 1, $frame->getSize()->width() - 1,
$frame->getSize()->getHeight() - 1, $frame->getSize()->height() - 1,
$color $color
); );
} }

View File

@@ -26,8 +26,8 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
{ {
// create new image // create new image
$modified = imagecreatetruecolor( $modified = imagecreatetruecolor(
$resize->getWidth(), $resize->width(),
$resize->getHeight() $resize->height()
); );
// get current image // get current image
@@ -53,18 +53,18 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
0, 0,
$crop->getPivot()->getX(), $crop->getPivot()->getX(),
$crop->getPivot()->getY(), $crop->getPivot()->getY(),
$resize->getWidth(), $resize->width(),
$resize->getHeight(), $resize->height(),
$crop->getWidth(), $crop->width(),
$crop->getHeight() $crop->height()
); );
imagedestroy($current); imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex); imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resize->getHeight(); ++$y) { for ($y = 0; $y < $resize->height(); ++$y) {
for ($x = 0; $x < $resize->getWidth(); ++$x) { for ($x = 0; $x < $resize->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) { if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel( imagesetpixel(
$modified, $modified,

View File

@@ -13,7 +13,7 @@ class PadDownModifier extends PadModifier
$resize = $this->getResizeSize($image); $resize = $this->getResizeSize($image);
return $image->size() return $image->size()
->contain($resize->getWidth(), $resize->getHeight()) ->contain($resize->width(), $resize->height())
->alignPivotTo($resize, $this->position); ->alignPivotTo($resize, $this->position);
} }

View File

@@ -36,8 +36,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
): void { ): void {
// create new image // create new image
$modified = imagecreatetruecolor( $modified = imagecreatetruecolor(
$resize->getWidth(), $resize->width(),
$resize->getHeight() $resize->height()
); );
imagefill($modified, 0, 0, $background); imagefill($modified, 0, 0, $background);
@@ -57,10 +57,10 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$crop->getPivot()->getY(), $crop->getPivot()->getY(),
0, 0,
0, 0,
$crop->getWidth(), $crop->width(),
$crop->getHeight(), $crop->height(),
$frame->getSize()->getWidth(), $frame->getSize()->width(),
$frame->getSize()->getHeight() $frame->getSize()->height()
); );
imagedestroy($current); imagedestroy($current);

View File

@@ -34,8 +34,8 @@ class ResizeModifier implements ModifierInterface
{ {
// create new image // create new image
$modified = imagecreatetruecolor( $modified = imagecreatetruecolor(
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight() $resizeTo->height()
); );
// get current image // get current image
@@ -61,18 +61,18 @@ class ResizeModifier implements ModifierInterface
$resizeTo->getPivot()->getY(), $resizeTo->getPivot()->getY(),
0, 0,
0, 0,
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight(), $resizeTo->height(),
$frame->getSize()->getWidth(), $frame->getSize()->width(),
$frame->getSize()->getHeight() $frame->getSize()->height()
); );
imagedestroy($current); imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex); imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resizeTo->getHeight(); ++$y) { for ($y = 0; $y < $resizeTo->height(); ++$y) {
for ($x = 0; $x < $resizeTo->getWidth(); ++$x) { for ($x = 0; $x < $resizeTo->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) { if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel( imagesetpixel(
$modified, $modified,

View File

@@ -55,8 +55,8 @@ class Image extends AbstractImage implements ImageInterface, Iterator
$size = $frame->getSize(); $size = $frame->getSize();
$imagick->setImagePage( $imagick->setImagePage(
$size->getWidth(), $size->width(),
$size->getHeight(), $size->height(),
$frame->getOffsetLeft(), $frame->getOffsetLeft(),
$frame->getOffsetTop() $frame->getOffsetTop()
); );

View File

@@ -26,8 +26,8 @@ class CropModifier implements ModifierInterface
foreach ($image as $frame) { foreach ($image as $frame) {
$frame->getCore()->extentImage( $frame->getCore()->extentImage(
$crop->getWidth(), $crop->width(),
$crop->getHeight(), $crop->height(),
$crop->getPivot()->getX() + $this->offset_x, $crop->getPivot()->getX() + $this->offset_x,
$crop->getPivot()->getY() + $this->offset_y $crop->getPivot()->getY() + $this->offset_y
); );

View File

@@ -15,15 +15,15 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
foreach ($image as $frame) { foreach ($image as $frame) {
$frame->getCore()->extentImage( $frame->getCore()->extentImage(
$crop->getWidth(), $crop->width(),
$crop->getHeight(), $crop->height(),
$crop->getPivot()->getX(), $crop->getPivot()->getX(),
$crop->getPivot()->getY() $crop->getPivot()->getY()
); );
$frame->getCore()->scaleImage( $frame->getCore()->scaleImage(
$resize->getWidth(), $resize->width(),
$resize->getHeight() $resize->height()
); );
} }

View File

@@ -13,7 +13,7 @@ class PadDownModifier extends PadModifier
$resize = $this->getResizeSize($image); $resize = $this->getResizeSize($image);
return $image->size() return $image->size()
->contain($resize->getWidth(), $resize->getHeight()) ->contain($resize->width(), $resize->height())
->alignPivotTo($resize, $this->position); ->alignPivotTo($resize, $this->position);
} }

View File

@@ -28,8 +28,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
foreach ($image as $frame) { foreach ($image as $frame) {
// resize current core // resize current core
$frame->getCore()->scaleImage( $frame->getCore()->scaleImage(
$crop->getWidth(), $crop->width(),
$crop->getHeight() $crop->height()
); );
// create new canvas, to get newly emerged background color // create new canvas, to get newly emerged background color
@@ -55,8 +55,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
{ {
// build base canvas in target size // build base canvas in target size
$canvas = $this->imageFactory()->newCore( $canvas = $this->imageFactory()->newCore(
$resize->getWidth(), $resize->width(),
$resize->getHeight() $resize->height()
); );
// draw background color on canvas // draw background color on canvas
@@ -73,8 +73,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$draw->rectangle( $draw->rectangle(
$crop->getPivot()->getX(), $crop->getPivot()->getX(),
$crop->getPivot()->getY(), $crop->getPivot()->getY(),
$crop->getPivot()->getX() + $crop->getWidth() - 1, $crop->getPivot()->getX() + $crop->width() - 1,
$crop->getPivot()->getY() + $crop->getHeight() - 1 $crop->getPivot()->getY() + $crop->height() - 1
); );
$canvas->drawImage($draw); $canvas->drawImage($draw);
$canvas->transparentPaintImage($fill, 0, 0, false); $canvas->transparentPaintImage($fill, 0, 0, false);

View File

@@ -27,10 +27,10 @@ class PixelateModifier implements ModifierInterface
$size = $frame->getSize(); $size = $frame->getSize();
$frame->getCore()->scaleImage( $frame->getCore()->scaleImage(
round(max(1, ($size->getWidth() / $this->size))), round(max(1, ($size->width() / $this->size))),
round(max(1, ($size->getHeight() / $this->size))) round(max(1, ($size->height() / $this->size)))
); );
$frame->getCore()->scaleImage($size->getWidth(), $size->getHeight()); $frame->getCore()->scaleImage($size->width(), $size->height());
} }
} }

View File

@@ -19,8 +19,8 @@ class ResizeModifier implements ModifierInterface
foreach ($image as $frame) { foreach ($image as $frame) {
$frame->getCore()->scaleImage( $frame->getCore()->scaleImage(
$resizeTo->getWidth(), $resizeTo->width(),
$resizeTo->getHeight() $resizeTo->height()
); );
} }

View File

@@ -159,7 +159,7 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
* *
* @return int * @return int
*/ */
public function getWidth(): int public function width(): int
{ {
return abs($this->getMostLeftPoint()->getX() - $this->getMostRightPoint()->getX()); return abs($this->getMostLeftPoint()->getX() - $this->getMostRightPoint()->getX());
} }
@@ -169,7 +169,7 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
* *
* @return int * @return int
*/ */
public function getHeight(): int public function height(): int
{ {
return abs($this->getMostBottomPoint()->getY() - $this->getMostTopPoint()->getY()); return abs($this->getMostBottomPoint()->getY() - $this->getMostTopPoint()->getY());
} }
@@ -270,8 +270,8 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
public function getCenterPoint(): Point public function getCenterPoint(): Point
{ {
return new Point( return new Point(
$this->getMostRightPoint()->getX() - (intval(round($this->getWidth() / 2))), $this->getMostRightPoint()->getX() - (intval(round($this->width() / 2))),
$this->getMostTopPoint()->getY() - (intval(round($this->getHeight() / 2))) $this->getMostTopPoint()->getY() - (intval(round($this->height() / 2)))
); );
} }
@@ -323,12 +323,12 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
break; break;
case 'top': case 'top':
$diff = ($this->getMostTopPoint()->getY() - $this->getPivot()->getY()) - $this->getHeight(); $diff = ($this->getMostTopPoint()->getY() - $this->getPivot()->getY()) - $this->height();
break; break;
default: default:
case 'bottom': case 'bottom':
$diff = ($this->getMostBottomPoint()->getY() - $this->getPivot()->getY()) + $this->getHeight(); $diff = ($this->getMostBottomPoint()->getY() - $this->getPivot()->getY()) + $this->height();
break; break;
} }

View File

@@ -91,13 +91,13 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'top-middle': case 'top-middle':
case 'center-top': case 'center-top':
case 'middle-top': case 'middle-top':
$x = intval($this->getWidth() / 2) + $offset_x; $x = intval($this->width() / 2) + $offset_x;
$y = 0 + $offset_y; $y = 0 + $offset_y;
break; break;
case 'top-right': case 'top-right':
case 'right-top': case 'right-top':
$x = $this->getWidth() - $offset_x; $x = $this->width() - $offset_x;
$y = 0 + $offset_y; $y = 0 + $offset_y;
break; break;
@@ -107,7 +107,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'center-left': case 'center-left':
case 'middle-left': case 'middle-left':
$x = 0 + $offset_x; $x = 0 + $offset_x;
$y = intval($this->getHeight() / 2) + $offset_y; $y = intval($this->height() / 2) + $offset_y;
break; break;
case 'right': case 'right':
@@ -115,14 +115,14 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'right-middle': case 'right-middle':
case 'center-right': case 'center-right':
case 'middle-right': case 'middle-right':
$x = $this->getWidth() - $offset_x; $x = $this->width() - $offset_x;
$y = intval($this->getHeight() / 2) + $offset_y; $y = intval($this->height() / 2) + $offset_y;
break; break;
case 'bottom-left': case 'bottom-left':
case 'left-bottom': case 'left-bottom':
$x = 0 + $offset_x; $x = 0 + $offset_x;
$y = $this->getHeight() - $offset_y; $y = $this->height() - $offset_y;
break; break;
case 'bottom': case 'bottom':
@@ -130,22 +130,22 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'bottom-middle': case 'bottom-middle':
case 'center-bottom': case 'center-bottom':
case 'middle-bottom': case 'middle-bottom':
$x = intval($this->getWidth() / 2) + $offset_x; $x = intval($this->width() / 2) + $offset_x;
$y = $this->getHeight() - $offset_y; $y = $this->height() - $offset_y;
break; break;
case 'bottom-right': case 'bottom-right':
case 'right-bottom': case 'right-bottom':
$x = $this->getWidth() - $offset_x; $x = $this->width() - $offset_x;
$y = $this->getHeight() - $offset_y; $y = $this->height() - $offset_y;
break; break;
case 'center': case 'center':
case 'middle': case 'middle':
case 'center-center': case 'center-center':
case 'middle-middle': case 'middle-middle':
$x = intval($this->getWidth() / 2) + $offset_x; $x = intval($this->width() / 2) + $offset_x;
$y = intval($this->getHeight() / 2) + $offset_y; $y = intval($this->height() / 2) + $offset_y;
break; break;
default: default:
@@ -163,7 +163,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
public function alignPivotTo(SizeInterface $size, string $position): self public function alignPivotTo(SizeInterface $size, string $position): self
{ {
$reference = new self($size->getWidth(), $size->getHeight()); $reference = new self($size->width(), $size->height());
$reference->movePivot($position); $reference->movePivot($position);
$this->movePivot($position)->setPivot( $this->movePivot($position)->setPivot(
@@ -190,16 +190,16 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
public function getAspectRatio(): float public function getAspectRatio(): float
{ {
return $this->getWidth() / $this->getHeight(); return $this->width() / $this->height();
} }
public function fitsInto(SizeInterface $size): bool public function fitsInto(SizeInterface $size): bool
{ {
if ($this->getWidth() > $size->getWidth()) { if ($this->width() > $size->width()) {
return false; return false;
} }
if ($this->getHeight() > $size->getHeight()) { if ($this->height() > $size->height()) {
return false; return false;
} }
@@ -213,7 +213,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
*/ */
public function isLandscape(): bool public function isLandscape(): bool
{ {
return $this->getWidth() > $this->getHeight(); return $this->width() > $this->height();
} }
/** /**
@@ -223,7 +223,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
*/ */
public function isPortrait(): bool public function isPortrait(): bool
{ {
return $this->getWidth() < $this->getHeight(); return $this->width() < $this->height();
} }
public function topLeftPoint(): PointInterface public function topLeftPoint(): PointInterface

View File

@@ -65,8 +65,8 @@ class RectangleResizer
public function toSize(SizeInterface $size): self public function toSize(SizeInterface $size): self
{ {
$this->width = $size->getWidth(); $this->width = $size->width();
$this->height = $size->getHeight(); $this->height = $size->height();
return $this; return $this;
} }
@@ -74,7 +74,7 @@ class RectangleResizer
protected function getProportionalWidth(SizeInterface $size): int protected function getProportionalWidth(SizeInterface $size): int
{ {
if (! $this->hasTargetHeight()) { if (! $this->hasTargetHeight()) {
return $size->getWidth(); return $size->width();
} }
return (int) round($this->height * $size->getAspectRatio()); return (int) round($this->height * $size->getAspectRatio());
@@ -83,7 +83,7 @@ class RectangleResizer
protected function getProportionalHeight(SizeInterface $size): int protected function getProportionalHeight(SizeInterface $size): int
{ {
if (! $this->hasTargetWidth()) { if (! $this->hasTargetWidth()) {
return $size->getHeight(); return $size->height();
} }
return (int) round($this->width / $size->getAspectRatio()); return (int) round($this->width / $size->getAspectRatio());
@@ -91,7 +91,7 @@ class RectangleResizer
public function resize(SizeInterface $size): SizeInterface public function resize(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
if ($width = $this->getTargetWidth()) { if ($width = $this->getTargetWidth()) {
$resized->setWidth($width); $resized->setWidth($width);
@@ -106,17 +106,17 @@ class RectangleResizer
public function resizeDown(SizeInterface $size): SizeInterface public function resizeDown(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
if ($width = $this->getTargetWidth()) { if ($width = $this->getTargetWidth()) {
$resized->setWidth( $resized->setWidth(
min($width, $size->getWidth()) min($width, $size->width())
); );
} }
if ($height = $this->getTargetHeight()) { if ($height = $this->getTargetHeight()) {
$resized->setHeight( $resized->setHeight(
min($height, $size->getHeight()) min($height, $size->height())
); );
} }
@@ -125,7 +125,7 @@ class RectangleResizer
public function scale(SizeInterface $size): SizeInterface public function scale(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
if ($this->hasTargetWidth() && $this->hasTargetHeight()) { if ($this->hasTargetWidth() && $this->hasTargetHeight()) {
$resized->setWidth(min( $resized->setWidth(min(
@@ -149,36 +149,36 @@ class RectangleResizer
public function scaleDown(SizeInterface $size): SizeInterface public function scaleDown(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
if ($this->hasTargetWidth() && $this->hasTargetHeight()) { if ($this->hasTargetWidth() && $this->hasTargetHeight()) {
$resized->setWidth(min( $resized->setWidth(min(
$this->getProportionalWidth($size), $this->getProportionalWidth($size),
$this->getTargetWidth(), $this->getTargetWidth(),
$size->getWidth() $size->width()
)); ));
$resized->setHeight(min( $resized->setHeight(min(
$this->getProportionalHeight($size), $this->getProportionalHeight($size),
$this->getTargetHeight(), $this->getTargetHeight(),
$size->getHeight() $size->height()
)); ));
} elseif ($this->hasTargetWidth()) { } elseif ($this->hasTargetWidth()) {
$resized->setWidth(min( $resized->setWidth(min(
$this->getTargetWidth(), $this->getTargetWidth(),
$size->getWidth() $size->width()
)); ));
$resized->setHeight(min( $resized->setHeight(min(
$this->getProportionalHeight($size), $this->getProportionalHeight($size),
$size->getHeight() $size->height()
)); ));
} elseif ($this->hasTargetHeight()) { } elseif ($this->hasTargetHeight()) {
$resized->setWidth(min( $resized->setWidth(min(
$this->getProportionalWidth($size), $this->getProportionalWidth($size),
$size->getWidth() $size->width()
)); ));
$resized->setHeight(min( $resized->setHeight(min(
$this->getTargetHeight(), $this->getTargetHeight(),
$size->getHeight() $size->height()
)); ));
} }
@@ -193,7 +193,7 @@ class RectangleResizer
*/ */
public function cover(SizeInterface $size): SizeInterface public function cover(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
// auto height // auto height
$resized->setWidth($this->getTargetWidth()); $resized->setWidth($this->getTargetWidth());
@@ -216,7 +216,7 @@ class RectangleResizer
*/ */
public function contain(SizeInterface $size): SizeInterface public function contain(SizeInterface $size): SizeInterface
{ {
$resized = new Rectangle($size->getWidth(), $size->getHeight()); $resized = new Rectangle($size->width(), $size->height());
// auto height // auto height
$resized->setWidth($this->getTargetWidth()); $resized->setWidth($this->getTargetWidth());

View File

@@ -4,8 +4,8 @@ namespace Intervention\Image\Interfaces;
interface SizeInterface interface SizeInterface
{ {
public function getWidth(): int; public function width(): int;
public function getHeight(): int; public function height(): int;
public function getPivot(): PointInterface; public function getPivot(): PointInterface;
public function setWidth(int $width): SizeInterface; public function setWidth(int $width): SizeInterface;
public function setHeight(int $height): SizeInterface; public function setHeight(int $height): SizeInterface;

View File

@@ -28,7 +28,7 @@ class Line
public function widthInFont(FontInterface $font): int public function widthInFont(FontInterface $font): int
{ {
return $font->getBoxSize($this->text)->getWidth(); return $font->getBoxSize($this->text)->width();
} }
public function __toString(): string public function __toString(): string

View File

@@ -45,16 +45,16 @@ class AbstractImageTest extends TestCase
{ {
$img = $this->abstractImageMock(); $img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->size()); $this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth()); $this->assertEquals(300, $img->size()->width());
$this->assertEquals(200, $img->size()->getHeight()); $this->assertEquals(200, $img->size()->height());
} }
public function testSizeAlias(): void public function testSizeAlias(): void
{ {
$img = $this->abstractImageMock(); $img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->size()); $this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth()); $this->assertEquals(300, $img->size()->width());
$this->assertEquals(200, $img->size()->getHeight()); $this->assertEquals(200, $img->size()->height());
} }
public function testModify(): void public function testModify(): void

View File

@@ -29,8 +29,8 @@ class AbstractFitModifierTest extends TestCase
$image = (new ImageFactory())->newImage($width, $height); $image = (new ImageFactory())->newImage($width, $height);
$size = $modifier->getCropSize($image); $size = $modifier->getCropSize($image);
static::assertSame($expectedWidth, $size->getWidth()); static::assertSame($expectedWidth, $size->width());
static::assertSame($expectedHeight, $size->getHeight()); static::assertSame($expectedHeight, $size->height());
static::assertSame($expectedX, $size->getPivot()->getX()); static::assertSame($expectedX, $size->getPivot()->getX());
static::assertSame($expectedY, $size->getPivot()->getY()); static::assertSame($expectedY, $size->getPivot()->getY());
} }
@@ -43,8 +43,8 @@ class AbstractFitModifierTest extends TestCase
$size = $modifier->getCropSize($image); $size = $modifier->getCropSize($image);
$resize = $modifier->getResizeSize($size); $resize = $modifier->getResizeSize($size);
static::assertSame(200, $resize->getWidth()); static::assertSame(200, $resize->width());
static::assertSame(100, $resize->getHeight()); static::assertSame(100, $resize->height());
static::assertSame(0, $resize->getPivot()->getX()); static::assertSame(0, $resize->getPivot()->getX());
static::assertSame(0, $resize->getPivot()->getY()); static::assertSame(0, $resize->getPivot()->getY());
} }

View File

@@ -31,8 +31,8 @@ final class AbstractPadModifierTest extends TestCase
$image = (new ImageFactory())->newImage($width, $height); $image = (new ImageFactory())->newImage($width, $height);
$size = $modifier->getCropSize($image); $size = $modifier->getCropSize($image);
static::assertSame($expectedWidth, $size->getWidth()); static::assertSame($expectedWidth, $size->width());
static::assertSame($expectedHeight, $size->getHeight()); static::assertSame($expectedHeight, $size->height());
static::assertSame($expectedX, $size->getPivot()->getX()); static::assertSame($expectedX, $size->getPivot()->getX());
static::assertSame($expectedY, $size->getPivot()->getY()); static::assertSame($expectedY, $size->getPivot()->getY());
} }
@@ -44,8 +44,8 @@ final class AbstractPadModifierTest extends TestCase
$image = (new ImageFactory())->newImage(300, 200); $image = (new ImageFactory())->newImage(300, 200);
$resize = $modifier->getResizeSize($image); $resize = $modifier->getResizeSize($image);
static::assertSame(200, $resize->getWidth()); static::assertSame(200, $resize->width());
static::assertSame(100, $resize->getHeight()); static::assertSame(100, $resize->height());
static::assertSame(0, $resize->getPivot()->getX()); static::assertSame(0, $resize->getPivot()->getX());
static::assertSame(0, $resize->getPivot()->getY()); static::assertSame(0, $resize->getPivot()->getY());
} }

View File

@@ -36,10 +36,10 @@ class FrameTest extends TestCase
$core1 = imagecreatetruecolor(3, 2); $core1 = imagecreatetruecolor(3, 2);
$core2 = imagecreatetruecolor(3, 3); $core2 = imagecreatetruecolor(3, 3);
$frame = new Frame($core1); $frame = new Frame($core1);
$this->assertEquals(2, $frame->getSize()->getHeight()); $this->assertEquals(2, $frame->getSize()->height());
$result = $frame->setCore($core2); $result = $frame->setCore($core2);
$this->assertInstanceOf(Frame::class, $result); $this->assertInstanceOf(Frame::class, $result);
$this->assertEquals(3, $frame->getSize()->getHeight()); $this->assertEquals(3, $frame->getSize()->height());
} }
public function testGetSize(): void public function testGetSize(): void

View File

@@ -72,7 +72,7 @@ class PolygonTest extends TestCase
new Point(3, 566), new Point(3, 566),
]); ]);
$this->assertEquals($poly->getWidth(), 35); $this->assertEquals($poly->width(), 35);
} }
public function testGetHeight(): void public function testGetHeight(): void
@@ -83,7 +83,7 @@ class PolygonTest extends TestCase
new Point(3, 566), new Point(3, 566),
]); ]);
$this->assertEquals(615, $poly->getHeight()); $this->assertEquals(615, $poly->height());
$poly = new Polygon([ $poly = new Polygon([
new Point(250, 207), new Point(250, 207),
@@ -92,7 +92,7 @@ class PolygonTest extends TestCase
new Point(250, 250), new Point(250, 250),
], new Point(250, 250)); ], new Point(250, 250));
$this->assertEquals(43, $poly->getHeight()); $this->assertEquals(43, $poly->height());
} }
public function testFirst(): void public function testFirst(): void

View File

@@ -54,28 +54,28 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(150); $resizer->toWidth(150);
$result = $resizer->resize($size); $result = $resizer->resize($size);
$this->assertEquals(150, $result->getWidth()); $this->assertEquals(150, $result->width());
$this->assertEquals(200, $result->getHeight()); $this->assertEquals(200, $result->height());
$size = new Rectangle(300, 200); $size = new Rectangle(300, 200);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(20); $resizer->toWidth(20);
$resizer->toHeight(10); $resizer->toHeight(10);
$result = $resizer->resize($size); $result = $resizer->resize($size);
$this->assertEquals(20, $result->getWidth()); $this->assertEquals(20, $result->width());
$this->assertEquals(10, $result->getHeight()); $this->assertEquals(10, $result->height());
$size = new Rectangle(300, 200); $size = new Rectangle(300, 200);
$resizer = new RectangleResizer(width: 150); $resizer = new RectangleResizer(width: 150);
$result = $resizer->resize($size); $result = $resizer->resize($size);
$this->assertEquals(150, $result->getWidth()); $this->assertEquals(150, $result->width());
$this->assertEquals(200, $result->getHeight()); $this->assertEquals(200, $result->height());
$size = new Rectangle(300, 200); $size = new Rectangle(300, 200);
$resizer = new RectangleResizer(height: 10, width: 20); $resizer = new RectangleResizer(height: 10, width: 20);
$result = $resizer->resize($size); $result = $resizer->resize($size);
$this->assertEquals(20, $result->getWidth()); $this->assertEquals(20, $result->width());
$this->assertEquals(10, $result->getHeight()); $this->assertEquals(10, $result->height());
} }
public function testResizeDown() public function testResizeDown()
@@ -86,8 +86,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(2000); $resizer->toHeight(2000);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
// 800x600 > 400x1000 = 400x600 // 800x600 > 400x1000 = 400x600
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -95,8 +95,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(1000); $resizer->toHeight(1000);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
// 800x600 > 1000x400 = 800x400 // 800x600 > 1000x400 = 800x400
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -104,8 +104,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(400); $resizer->toHeight(400);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(400, $result->getHeight()); $this->assertEquals(400, $result->height());
// 800x600 > 400x300 = 400x300 // 800x600 > 400x300 = 400x300
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -113,24 +113,24 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
// 800x600 > 1000xnull = 800x600 // 800x600 > 1000xnull = 800x600
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(1000); $resizer->toWidth(1000);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
// 800x600 > nullx1000 = 800x600 // 800x600 > nullx1000 = 800x600
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toHeight(1000); $resizer->toHeight(1000);
$result = $resizer->resizeDown($size); $result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
} }
public function testScale() public function testScale()
@@ -141,8 +141,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(2000); $resizer->toHeight(2000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(1000, $result->getWidth()); $this->assertEquals(1000, $result->width());
$this->assertEquals(750, $result->getHeight()); $this->assertEquals(750, $result->height());
// 800x600 > 2000x1000 = 1333x1000 // 800x600 > 2000x1000 = 1333x1000
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -150,24 +150,24 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(2000); $resizer->toWidth(2000);
$resizer->toHeight(1000); $resizer->toHeight(1000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(1333, $result->getWidth()); $this->assertEquals(1333, $result->width());
$this->assertEquals(1000, $result->getHeight()); $this->assertEquals(1000, $result->height());
// // 800x600 > nullx3000 = 4000x3000 // // 800x600 > nullx3000 = 4000x3000
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toHeight(3000); $resizer->toHeight(3000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth()); $this->assertEquals(4000, $result->width());
$this->assertEquals(3000, $result->getHeight()); $this->assertEquals(3000, $result->height());
// // 800x600 > 8000xnull = 8000x6000 // // 800x600 > 8000xnull = 8000x6000
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(8000); $resizer->toWidth(8000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(8000, $result->getWidth()); $this->assertEquals(8000, $result->width());
$this->assertEquals(6000, $result->getHeight()); $this->assertEquals(6000, $result->height());
// // 800x600 > 100x400 = 100x75 // // 800x600 > 100x400 = 100x75
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -175,8 +175,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(100); $resizer->toWidth(100);
$resizer->toHeight(400); $resizer->toHeight(400);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(100, $result->getWidth()); $this->assertEquals(100, $result->width());
$this->assertEquals(75, $result->getHeight()); $this->assertEquals(75, $result->height());
// // 800x600 > 400x100 = 133x100 // // 800x600 > 400x100 = 133x100
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -184,40 +184,40 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(100); $resizer->toHeight(100);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(133, $result->getWidth()); $this->assertEquals(133, $result->width());
$this->assertEquals(100, $result->getHeight()); $this->assertEquals(100, $result->height());
// // 800x600 > nullx300 = 400x300 // // 800x600 > nullx300 = 400x300
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
// // 800x600 > 80xnull = 80x60 // // 800x600 > 80xnull = 80x60
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(80); $resizer->toWidth(80);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(80, $result->getWidth()); $this->assertEquals(80, $result->width());
$this->assertEquals(60, $result->getHeight()); $this->assertEquals(60, $result->height());
// // 640x480 > 225xnull = 225x169 // // 640x480 > 225xnull = 225x169
$size = new Rectangle(640, 480); $size = new Rectangle(640, 480);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(225); $resizer->toWidth(225);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(225, $result->getWidth()); $this->assertEquals(225, $result->width());
$this->assertEquals(169, $result->getHeight()); $this->assertEquals(169, $result->height());
// // 640x480 > 223xnull = 223x167 // // 640x480 > 223xnull = 223x167
$size = new Rectangle(640, 480); $size = new Rectangle(640, 480);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(223); $resizer->toWidth(223);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(223, $result->getWidth()); $this->assertEquals(223, $result->width());
$this->assertEquals(167, $result->getHeight()); $this->assertEquals(167, $result->height());
// // 600x800 > 300x300 = 225x300 // // 600x800 > 300x300 = 225x300
$size = new Rectangle(600, 800); $size = new Rectangle(600, 800);
@@ -225,8 +225,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(300); $resizer->toWidth(300);
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(225, $result->getWidth()); $this->assertEquals(225, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
// // 800x600 > 400x10 = 13x10 // // 800x600 > 400x10 = 13x10
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -234,8 +234,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(10); $resizer->toHeight(10);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(13, $result->getWidth()); $this->assertEquals(13, $result->width());
$this->assertEquals(10, $result->getHeight()); $this->assertEquals(10, $result->height());
// // 800x600 > 1000x1200 = 1000x750 // // 800x600 > 1000x1200 = 1000x750
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
@@ -243,32 +243,32 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(1200); $resizer->toHeight(1200);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(1000, $result->getWidth()); $this->assertEquals(1000, $result->width());
$this->assertEquals(750, $result->getHeight()); $this->assertEquals(750, $result->height());
$size = new Rectangle(12000, 12); $size = new Rectangle(12000, 12);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(4000); $resizer->toWidth(4000);
$resizer->toHeight(3000); $resizer->toHeight(3000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth()); $this->assertEquals(4000, $result->width());
$this->assertEquals(4, $result->getHeight()); $this->assertEquals(4, $result->height());
$size = new Rectangle(12, 12000); $size = new Rectangle(12, 12000);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(4000); $resizer->toWidth(4000);
$resizer->toHeight(3000); $resizer->toHeight(3000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(3, $result->getWidth()); $this->assertEquals(3, $result->width());
$this->assertEquals(3000, $result->getHeight()); $this->assertEquals(3000, $result->height());
$size = new Rectangle(12000, 6000); $size = new Rectangle(12000, 6000);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(4000); $resizer->toWidth(4000);
$resizer->toHeight(3000); $resizer->toHeight(3000);
$result = $resizer->scale($size); $result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth()); $this->assertEquals(4000, $result->width());
$this->assertEquals(2000, $result->getHeight()); $this->assertEquals(2000, $result->height());
} }
public function testScaleDown() public function testScaleDown()
@@ -278,91 +278,91 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(2000); $resizer->toHeight(2000);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(600); $resizer->toHeight(600);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(1000); $resizer->toWidth(1000);
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(1000); $resizer->toHeight(1000);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(400); $resizer->toWidth(400);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth()); $this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(1000); $resizer->toWidth(1000);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toHeight(1000); $resizer->toHeight(1000);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth()); $this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->getHeight()); $this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(100); $resizer->toWidth(100);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(100, $result->getWidth()); $this->assertEquals(100, $result->width());
$this->assertEquals(75, $result->getHeight()); $this->assertEquals(75, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(300); $resizer->toWidth(300);
$resizer->toHeight(200); $resizer->toHeight(200);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(267, $result->getWidth()); $this->assertEquals(267, $result->width());
$this->assertEquals(200, $result->getHeight()); $this->assertEquals(200, $result->height());
$size = new Rectangle(600, 800); $size = new Rectangle(600, 800);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(300); $resizer->toWidth(300);
$resizer->toHeight(300); $resizer->toHeight(300);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(225, $result->getWidth()); $this->assertEquals(225, $result->width());
$this->assertEquals(300, $result->getHeight()); $this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toWidth(400); $resizer->toWidth(400);
$resizer->toHeight(10); $resizer->toHeight(10);
$result = $resizer->scaleDown($size); $result = $resizer->scaleDown($size);
$this->assertEquals(13, $result->getWidth()); $this->assertEquals(13, $result->width());
$this->assertEquals(10, $result->getHeight()); $this->assertEquals(10, $result->height());
} }
/** /**
@@ -373,8 +373,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toSize($target); $resizer->toSize($target);
$resized = $resizer->cover($origin); $resized = $resizer->cover($origin);
$this->assertEquals($result->getWidth(), $resized->getWidth()); $this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->getHeight(), $resized->getHeight()); $this->assertEquals($result->height(), $resized->height());
} }
public function coverDataProvider(): array public function coverDataProvider(): array
@@ -400,8 +400,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toSize($target); $resizer->toSize($target);
$resized = $resizer->contain($origin); $resized = $resizer->contain($origin);
$this->assertEquals($result->getWidth(), $resized->getWidth()); $this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->getHeight(), $resized->getHeight()); $this->assertEquals($result->height(), $resized->height());
} }
public function containDataProvider(): array public function containDataProvider(): array
@@ -427,8 +427,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer(); $resizer = new RectangleResizer();
$resizer->toSize($target); $resizer->toSize($target);
$resized = $resizer->crop($origin, $position); $resized = $resizer->crop($origin, $position);
$this->assertEquals($result->getWidth(), $resized->getWidth()); $this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->getHeight(), $resized->getHeight()); $this->assertEquals($result->height(), $resized->height());
$this->assertEquals($result->getPivot()->getX(), $resized->getPivot()->getX()); $this->assertEquals($result->getPivot()->getX(), $resized->getPivot()->getX());
$this->assertEquals($result->getPivot()->getY(), $resized->getPivot()->getY()); $this->assertEquals($result->getPivot()->getY(), $resized->getPivot()->getY());
} }

View File

@@ -19,32 +19,32 @@ class RectangleTest extends TestCase
$this->assertEquals(-200, $rectangle[2]->getY()); $this->assertEquals(-200, $rectangle[2]->getY());
$this->assertEquals(0, $rectangle[3]->getX()); $this->assertEquals(0, $rectangle[3]->getX());
$this->assertEquals(-200, $rectangle[3]->getY()); $this->assertEquals(-200, $rectangle[3]->getY());
$this->assertEquals(300, $rectangle->getWidth()); $this->assertEquals(300, $rectangle->width());
$this->assertEquals(200, $rectangle->getHeight()); $this->assertEquals(200, $rectangle->height());
} }
public function testSetSize(): void public function testSetSize(): void
{ {
$rectangle = new Rectangle(300, 200); $rectangle = new Rectangle(300, 200);
$rectangle->setSize(12, 34); $rectangle->setSize(12, 34);
$this->assertEquals(12, $rectangle->getWidth()); $this->assertEquals(12, $rectangle->width());
$this->assertEquals(34, $rectangle->getHeight()); $this->assertEquals(34, $rectangle->height());
} }
public function testSetWidth(): void public function testSetWidth(): void
{ {
$rectangle = new Rectangle(300, 200); $rectangle = new Rectangle(300, 200);
$this->assertEquals(300, $rectangle->getWidth()); $this->assertEquals(300, $rectangle->width());
$rectangle->setWidth(400); $rectangle->setWidth(400);
$this->assertEquals(400, $rectangle->getWidth()); $this->assertEquals(400, $rectangle->width());
} }
public function testSetHeight(): void public function testSetHeight(): void
{ {
$rectangle = new Rectangle(300, 200); $rectangle = new Rectangle(300, 200);
$this->assertEquals(200, $rectangle->getHeight()); $this->assertEquals(200, $rectangle->height());
$rectangle->setHeight(800); $rectangle->setHeight(800);
$this->assertEquals(800, $rectangle->getHeight()); $this->assertEquals(800, $rectangle->height());
} }
public function testGetAspectRatio() public function testGetAspectRatio()

View File

@@ -71,8 +71,8 @@ class TextBlockTest extends TestCase
$font->shouldReceive('capHeight')->andReturn(22); $font->shouldReceive('capHeight')->andReturn(22);
$box = $block->getBoundingBox($font, new Point(10, 15)); $box = $block->getBoundingBox($font, new Point(10, 15));
$this->assertEquals(300, $box->getWidth()); $this->assertEquals(300, $box->width());
$this->assertEquals(82, $box->getHeight()); $this->assertEquals(82, $box->height());
$this->assertEquals(10, $box->getPivot()->getX()); $this->assertEquals(10, $box->getPivot()->getX());
$this->assertEquals(15, $box->getPivot()->getY()); $this->assertEquals(15, $box->getPivot()->getY());
} }