1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 20:21:32 +02:00

Rename methods

Rename fit() to cover() and fitDown() to coverDown()
This commit is contained in:
Oliver Vogel
2023-12-05 18:34:27 +01:00
parent 809bd1628f
commit 38b85fa0f6
10 changed files with 26 additions and 26 deletions

View File

@@ -8,7 +8,7 @@ use Intervention\Image\Interfaces\SizeInterface;
* @property int $width
* @property int $height
*/
class FitDownModifier extends FitModifier
class CoverDownModifier extends CoverModifier
{
public function getResizeSize(SizeInterface $size): SizeInterface
{

View File

@@ -11,7 +11,7 @@ use Intervention\Image\Interfaces\SizeInterface;
* @method SizeInterface getResizeSize(ImageInterface $image)
* @method SizeInterface getCropSize(ImageInterface $image)
*/
class FitModifier extends DriverSpecializedModifier
class CoverModifier extends DriverSpecializedModifier
{
public function apply(ImageInterface $image): ImageInterface
{

View File

@@ -8,7 +8,7 @@ use Intervention\Image\Interfaces\SizeInterface;
* @property int $width
* @property int $height
*/
class FitDownModifier extends FitModifier
class CoverDownModifier extends CoverModifier
{
public function getResizeSize(SizeInterface $size): SizeInterface
{

View File

@@ -10,7 +10,7 @@ use Intervention\Image\Interfaces\SizeInterface;
* @method SizeInterface getResizeSize(ImageInterface $image)
* @method SizeInterface getCropSize(ImageInterface $image)
*/
class FitModifier extends DriverSpecializedModifier
class CoverModifier extends DriverSpecializedModifier
{
public function apply(ImageInterface $image): ImageInterface
{

View File

@@ -51,8 +51,8 @@ use Intervention\Image\Modifiers\DrawPixelModifier;
use Intervention\Image\Modifiers\DrawPolygonModifier;
use Intervention\Image\Modifiers\DrawRectangleModifier;
use Intervention\Image\Modifiers\FillModifier;
use Intervention\Image\Modifiers\FitDownModifier;
use Intervention\Image\Modifiers\FitModifier;
use Intervention\Image\Modifiers\CoverDownModifier;
use Intervention\Image\Modifiers\CoverModifier;
use Intervention\Image\Modifiers\FlipModifier;
use Intervention\Image\Modifiers\FlopModifier;
use Intervention\Image\Modifiers\GammaModifier;
@@ -504,21 +504,21 @@ final class Image implements ImageInterface, Countable
/**
* {@inheritdoc}
*
* @see ImageInterface::fit()
* @see ImageInterface::cover()
*/
public function fit(int $width, int $height, string $position = 'center'): ImageInterface
public function cover(int $width, int $height, string $position = 'center'): ImageInterface
{
return $this->modify(new FitModifier($width, $height, $position));
return $this->modify(new CoverModifier($width, $height, $position));
}
/**
* {@inheritdoc}
*
* @see ImageInterface::fitDown()
* @see ImageInterface::coverDown()
*/
public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface
public function coverDown(int $width, int $height, string $position = 'center'): ImageInterface
{
return $this->modify(new FitDownModifier($width, $height, $position));
return $this->modify(new CoverDownModifier($width, $height, $position));
}
/**

View File

@@ -335,24 +335,24 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param string $position
* @return ImageInterface
*/
public function fit(int $width, int $height, string $position = 'center'): ImageInterface;
public function cover(int $width, int $height, string $position = 'center'): ImageInterface;
/**
* Same as fit() but do not exceed the original image size
* Same as cover() but do not exceed the original image size
*
* @param int $width
* @param int $height
* @param string $position
* @return ImageInterface
*/
public function fitDown(int $width, int $height, string $position = 'center'): ImageInterface;
public function coverDown(int $width, int $height, string $position = 'center'): ImageInterface;
/**
* Padded resizing means that the original image is scaled until it fits the
* defined target size with unchanged aspect ratio. The original image is
* not scaled up but only down.
*
* Compared to the fit() method, this method does not create cropped areas,
* Compared to the cover() method, this method does not create cropped areas,
* but possibly new empty areas on the sides of the result image. These are
* filled with the specified background color.
*

View File

@@ -2,6 +2,6 @@
namespace Intervention\Image\Modifiers;
class FitDownModifier extends FitModifier
class CoverDownModifier extends CoverModifier
{
}

View File

@@ -6,7 +6,7 @@ use Intervention\Image\Geometry\Rectangle;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\SizeInterface;
class FitModifier extends AbstractModifier
class CoverModifier extends AbstractModifier
{
public function __construct(
public int $width,

View File

@@ -2,15 +2,15 @@
namespace Intervention\Image\Tests\Drivers\Gd\Modifiers;
use Intervention\Image\Modifiers\FitModifier;
use Intervention\Image\Modifiers\CoverModifier;
use Intervention\Image\Tests\TestCase;
use Intervention\Image\Tests\Traits\CanCreateGdTestImage;
/**
* @requires extension gd
* @covers \Intervention\Image\Modifiers\FitModifier
* @covers \Intervention\Image\Modifiers\CoverModifier
*/
class FitModifierTest extends TestCase
class CoverModifierTest extends TestCase
{
use CanCreateGdTestImage;
@@ -19,7 +19,7 @@ class FitModifierTest extends TestCase
$image = $this->createTestImage('blocks.png');
$this->assertEquals(640, $image->width());
$this->assertEquals(480, $image->height());
$image->modify(new FitModifier(100, 100, 'center'));
$image->modify(new CoverModifier(100, 100, 'center'));
$this->assertEquals(100, $image->width());
$this->assertEquals(100, $image->height());
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));

View File

@@ -2,15 +2,15 @@
namespace Intervention\Image\Tests\Drivers\Imagick\Modifiers;
use Intervention\Image\Modifiers\FitModifier;
use Intervention\Image\Modifiers\CoverModifier;
use Intervention\Image\Tests\TestCase;
use Intervention\Image\Tests\Traits\CanCreateImagickTestImage;
/**
* @requires extension imagick
* @covers \Intervention\Image\Modifiers\FitModifier
* @covers \Intervention\Image\Modifiers\CoverModifier
*/
class FitModifierTest extends TestCase
class CoverModifierTest extends TestCase
{
use CanCreateImagickTestImage;
@@ -19,7 +19,7 @@ class FitModifierTest extends TestCase
$image = $this->createTestImage('blocks.png');
$this->assertEquals(640, $image->width());
$this->assertEquals(480, $image->height());
$image->modify(new FitModifier(100, 100, 'center'));
$image->modify(new CoverModifier(100, 100, 'center'));
$this->assertEquals(100, $image->width());
$this->assertEquals(100, $image->height());
$this->assertColor(255, 0, 0, 255, $image->pickColor(90, 90));