mirror of
https://github.com/Intervention/image.git
synced 2025-09-01 18:02:45 +02:00
Rename method
Image::getSize to Image::size
This commit is contained in:
@@ -38,14 +38,9 @@ abstract class AbstractImage implements ImageInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSize(): SizeInterface
|
||||
{
|
||||
return new Rectangle($this->width(), $this->height());
|
||||
}
|
||||
|
||||
public function size(): SizeInterface
|
||||
{
|
||||
return $this->getSize();
|
||||
return new Rectangle($this->width(), $this->height());
|
||||
}
|
||||
|
||||
public function modify(ModifierInterface $modifier): ImageInterface
|
||||
|
@@ -18,7 +18,7 @@ abstract class AbstractFitModifier
|
||||
|
||||
protected function getCropSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
$imagesize = $image->getSize();
|
||||
$imagesize = $image->size();
|
||||
|
||||
$crop = new Rectangle($this->width, $this->height);
|
||||
$crop = $crop->contain(
|
||||
|
@@ -22,7 +22,7 @@ abstract class AbstractPadModifier
|
||||
|
||||
protected function getCropSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()
|
||||
return $image->size()
|
||||
->contain($this->width, $this->height)
|
||||
->alignPivotTo($this->getResizeSize($image), $this->position);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class CropModifier implements ModifierInterface
|
||||
{
|
||||
$crop = new Rectangle($this->width, $this->height);
|
||||
$crop->align($this->position);
|
||||
$crop->alignPivotTo($image->getSize(), $this->position);
|
||||
$crop->alignPivotTo($image->size(), $this->position);
|
||||
|
||||
foreach ($image as $frame) {
|
||||
$this->cropFrame($frame, $crop);
|
||||
|
@@ -12,7 +12,7 @@ class PadDownModifier extends PadModifier
|
||||
{
|
||||
$resize = $this->getResizeSize($image);
|
||||
|
||||
return $image->getSize()
|
||||
return $image->size()
|
||||
->contain($resize->getWidth(), $resize->getHeight())
|
||||
->alignPivotTo($resize, $this->position);
|
||||
}
|
||||
|
@@ -48,8 +48,8 @@ class PlaceModifier implements ModifierInterface
|
||||
|
||||
protected function getPosition(ImageInterface $image, ImageInterface $watermark): PointInterface
|
||||
{
|
||||
$image_size = $image->getSize()->movePivot($this->position, $this->offset_x, $this->offset_y);
|
||||
$watermark_size = $watermark->getSize()->movePivot($this->position);
|
||||
$image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y);
|
||||
$watermark_size = $watermark->size()->movePivot($this->position);
|
||||
|
||||
return $image_size->getRelativePositionTo($watermark_size);
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ class ResizeDownModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->resizeDown($this->width, $this->height);
|
||||
return $image->size()->resizeDown($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ class ResizeModifier implements ModifierInterface
|
||||
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->resize($this->width, $this->height);
|
||||
return $image->size()->resize($this->width, $this->height);
|
||||
}
|
||||
|
||||
protected function resizeFrame(FrameInterface $frame, SizeInterface $resizeTo): void
|
||||
|
@@ -9,6 +9,6 @@ class ScaleDownModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->scaleDown($this->width, $this->height);
|
||||
return $image->size()->scaleDown($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ class ScaleModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->scale($this->width, $this->height);
|
||||
return $image->size()->scale($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ class CropModifier implements ModifierInterface
|
||||
{
|
||||
$crop = new Rectangle($this->width, $this->height);
|
||||
$crop->align($this->position);
|
||||
$crop->alignPivotTo($image->getSize(), $this->position);
|
||||
$crop->alignPivotTo($image->size(), $this->position);
|
||||
|
||||
foreach ($image as $frame) {
|
||||
$frame->getCore()->extentImage(
|
||||
|
@@ -12,7 +12,7 @@ class PadDownModifier extends PadModifier
|
||||
{
|
||||
$resize = $this->getResizeSize($image);
|
||||
|
||||
return $image->getSize()
|
||||
return $image->size()
|
||||
->contain($resize->getWidth(), $resize->getHeight())
|
||||
->alignPivotTo($resize, $this->position);
|
||||
}
|
||||
|
@@ -41,8 +41,8 @@ class PlaceModifier implements ModifierInterface
|
||||
|
||||
protected function getPosition(ImageInterface $image, Image $watermark): PointInterface
|
||||
{
|
||||
$image_size = $image->getSize()->movePivot($this->position, $this->offset_x, $this->offset_y);
|
||||
$watermark_size = $watermark->getSize()->movePivot($this->position);
|
||||
$image_size = $image->size()->movePivot($this->position, $this->offset_x, $this->offset_y);
|
||||
$watermark_size = $watermark->size()->movePivot($this->position);
|
||||
|
||||
return $image_size->getRelativePositionTo($watermark_size);
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ class ResizeDownModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->resizeDown($this->width, $this->height);
|
||||
return $image->size()->resizeDown($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,6 @@ class ResizeModifier implements ModifierInterface
|
||||
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->resize($this->width, $this->height);
|
||||
return $image->size()->resize($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ class ScaleDownModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->scaleDown($this->width, $this->height);
|
||||
return $image->size()->scaleDown($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ class ScaleModifier extends ResizeModifier
|
||||
{
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
{
|
||||
return $image->getSize()->scale($this->width, $this->height);
|
||||
return $image->size()->scale($this->width, $this->height);
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ interface ImageInterface extends Traversable, Countable
|
||||
*
|
||||
* @return SizeInterface
|
||||
*/
|
||||
public function getSize(): SizeInterface;
|
||||
public function size(): SizeInterface;
|
||||
|
||||
/**
|
||||
* Return exif data of current image
|
||||
|
@@ -44,15 +44,15 @@ class AbstractImageTest extends TestCase
|
||||
public function testGetSize(): void
|
||||
{
|
||||
$img = $this->abstractImageMock();
|
||||
$this->assertInstanceOf(Rectangle::class, $img->getSize());
|
||||
$this->assertEquals(300, $img->getSize()->getWidth());
|
||||
$this->assertEquals(200, $img->getSize()->getHeight());
|
||||
$this->assertInstanceOf(Rectangle::class, $img->size());
|
||||
$this->assertEquals(300, $img->size()->getWidth());
|
||||
$this->assertEquals(200, $img->size()->getHeight());
|
||||
}
|
||||
|
||||
public function testSizeAlias(): void
|
||||
{
|
||||
$img = $this->abstractImageMock();
|
||||
$this->assertInstanceOf(Rectangle::class, $img->getSize());
|
||||
$this->assertInstanceOf(Rectangle::class, $img->size());
|
||||
$this->assertEquals(300, $img->size()->getWidth());
|
||||
$this->assertEquals(200, $img->size()->getHeight());
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@ class ImageTest extends TestCase
|
||||
|
||||
public function testGetSize(): void
|
||||
{
|
||||
$this->assertInstanceOf(Rectangle::class, $this->image->getSize());
|
||||
$this->assertInstanceOf(Rectangle::class, $this->image->size());
|
||||
}
|
||||
|
||||
public function testPickColor(): void
|
||||
|
@@ -87,7 +87,7 @@ class ImageTest extends TestCase
|
||||
|
||||
public function testGetSize(): void
|
||||
{
|
||||
$this->assertInstanceOf(Rectangle::class, $this->image->getSize());
|
||||
$this->assertInstanceOf(Rectangle::class, $this->image->size());
|
||||
}
|
||||
|
||||
public function testGetColorspace(): void
|
||||
|
Reference in New Issue
Block a user