1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-23 05:52:47 +02:00

Rename methods

This commit is contained in:
Oliver Vogel
2025-06-22 16:13:52 +02:00
parent 9910226044
commit 83b6c0e73a
6 changed files with 40 additions and 40 deletions

View File

@@ -89,7 +89,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::create()
*/
public function decodeFromPath(string $path): ImageInterface
public function readPath(string $path): ImageInterface
{
return $this->driver->handleInput($path, [FilePathImageDecoder::class]);
}
@@ -99,7 +99,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::createFromBinary()
*/
public function decodeFromBinary(string $data): ImageInterface
public function readBinary(string $data): ImageInterface
{
return $this->driver->handleInput($data, [BinaryImageDecoder::class]);
}
@@ -109,7 +109,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::createFromBase64()
*/
public function decodeFromBase64(string $data): ImageInterface
public function readBase64(string $data): ImageInterface
{
return $this->driver->handleInput($data, [Base64ImageDecoder::class]);
}
@@ -119,7 +119,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::createFromDataUri()
*/
public function decodeFromDataUri(string $uri): ImageInterface
public function readDataUri(string $uri): ImageInterface
{
return $this->driver->handleInput($uri, [DataUriImageDecoder::class]);
}
@@ -129,7 +129,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::createFromStream()
*/
public function decodeFromStream(mixed $stream): ImageInterface
public function readStream(mixed $stream): ImageInterface
{
return $this->driver->handleInput($stream, [FilePointerImageDecoder::class]);
}
@@ -139,7 +139,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::createFromSplFileInfo()
*/
public function decodeFromSplFileInfo(SplFileInfo $file): ImageInterface
public function readSplFileInfo(SplFileInfo $file): ImageInterface
{
return $this->driver->handleInput($file, [SplFileInfoImageDecoder::class]);
}
@@ -149,7 +149,7 @@ final class ImageManager implements ImageManagerInterface
*
* @see ImageManagerInterface::read()
*/
public function decode(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface
public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface
{
return $this->driver->handleInput(
$input,

View File

@@ -24,42 +24,42 @@ interface ImageManagerInterface
*
* @throws DecoderException
*/
public function decodeFromPath(string $path): ImageInterface;
public function readPath(string $path): ImageInterface;
/**
* Create new image instance from given image binary data
*
* @throws DecoderException
*/
public function decodeFromBinary(string $data): ImageInterface;
public function readBinary(string $data): ImageInterface;
/**
* Create new image instance from given base64 encoded image data
*
* @throws DecoderException
*/
public function decodeFromBase64(string $data): ImageInterface;
public function readBase64(string $data): ImageInterface;
/**
* Create new image instance from given data uri encoded image data
*
* @throws DecoderException
*/
public function decodeFromDataUri(string $uri): ImageInterface;
public function readDataUri(string $uri): ImageInterface;
/**
* Create new image instance from given image stream resource
*
* @throws DecoderException
*/
public function decodeFromStream(mixed $stream): ImageInterface;
public function readStream(mixed $stream): ImageInterface;
/**
* Create new image instance from given SplFileInfo image object
*
* @throws DecoderException
*/
public function decodeFromSplFileInfo(SplFileInfo $file): ImageInterface;
public function readSplFileInfo(SplFileInfo $file): ImageInterface;
/**
* Create new image instance from given input which can be one of the following
@@ -89,7 +89,7 @@ interface ImageManagerInterface
* @param string|array<string|DecoderInterface>|DecoderInterface $decoders
* @throws RuntimeException
*/
public function decode(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface;
public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface;
/**
* Create new animated image by given callback

View File

@@ -14,7 +14,7 @@ class ConvertPngGif extends GdTestCase
public function testConversionKeepsTransparency(): void
{
$converted = ImageManager::gd()
->decode(
->read(
$this->readTestImage('circle.png')->toGif()
);

View File

@@ -14,7 +14,7 @@ class ConvertPngGif extends ImagickTestCase
public function testConversionKeepsTransparency(): void
{
$converted = ImageManager::imagick()
->decode(
->read(
$this->readTestImage('circle.png')->toGif()
);

View File

@@ -67,42 +67,42 @@ final class ImageManagerTestGd extends BaseTestCase
public function testRead(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'));
$image = $manager->read($this->getTestResourcePath('red.gif'));
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderClassname(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), FilePathImageDecoder::class);
$image = $manager->read($this->getTestResourcePath('red.gif'), FilePathImageDecoder::class);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstance(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), new FilePathImageDecoder());
$image = $manager->read($this->getTestResourcePath('red.gif'), new FilePathImageDecoder());
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderClassnameArray(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [FilePathImageDecoder::class]);
$image = $manager->read($this->getTestResourcePath('red.gif'), [FilePathImageDecoder::class]);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstanceArray(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [new FilePathImageDecoder()]);
$image = $manager->read($this->getTestResourcePath('red.gif'), [new FilePathImageDecoder()]);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstanceArrayMultiple(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [
$image = $manager->read($this->getTestResourcePath('red.gif'), [
new BinaryImageDecoder(),
new FilePathImageDecoder(),
]);
@@ -112,35 +112,35 @@ final class ImageManagerTestGd extends BaseTestCase
public function testReadWithRotationAdjustment(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('orientation.jpg'));
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
$this->assertColor(1, 0, 254, 255, $image->pickColor(3, 3));
}
public function testReadWithoutRotationAdjustment(): void
{
$manager = new ImageManager(Driver::class, autoOrientation: false);
$image = $manager->decode($this->getTestResourcePath('orientation.jpg'));
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
$this->assertColor(250, 2, 3, 255, $image->pickColor(3, 3));
}
public function testReadAnimation(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('animation.gif'));
$image = $manager->read($this->getTestResourcePath('animation.gif'));
$this->assertTrue($image->isAnimated());
}
public function testReadAnimationDiscarded(): void
{
$manager = new ImageManager(Driver::class, decodeAnimation: false);
$image = $manager->decode($this->getTestResourcePath('animation.gif'));
$image = $manager->read($this->getTestResourcePath('animation.gif'));
$this->assertFalse($image->isAnimated());
}
public function testApplyBackgroundColorDefault(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('blocks.png'));
$image = $manager->read($this->getTestResourcePath('blocks.png'));
$result = $image->background();
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
@@ -149,7 +149,7 @@ final class ImageManagerTestGd extends BaseTestCase
public function testApplyBackgroundColorConfigured(): void
{
$manager = new ImageManager(Driver::class, backgroundColor: 'ff5500');
$image = $manager->decode($this->getTestResourcePath('blocks.png'));
$image = $manager->read($this->getTestResourcePath('blocks.png'));
$result = $image->background();
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));

View File

@@ -67,42 +67,42 @@ final class ImageManagerTestImagick extends BaseTestCase
public function testRead(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'));
$image = $manager->read($this->getTestResourcePath('red.gif'));
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderClassname(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), FilePathImageDecoder::class);
$image = $manager->read($this->getTestResourcePath('red.gif'), FilePathImageDecoder::class);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstance(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), new FilePathImageDecoder());
$image = $manager->read($this->getTestResourcePath('red.gif'), new FilePathImageDecoder());
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderClassnameArray(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [FilePathImageDecoder::class]);
$image = $manager->read($this->getTestResourcePath('red.gif'), [FilePathImageDecoder::class]);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstanceArray(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [new FilePathImageDecoder()]);
$image = $manager->read($this->getTestResourcePath('red.gif'), [new FilePathImageDecoder()]);
$this->assertInstanceOf(ImageInterface::class, $image);
}
public function testReadWithDecoderInstanceArrayMultiple(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('red.gif'), [
$image = $manager->read($this->getTestResourcePath('red.gif'), [
new BinaryImageDecoder(),
new FilePathImageDecoder(),
]);
@@ -112,35 +112,35 @@ final class ImageManagerTestImagick extends BaseTestCase
public function testReadWithRotationAdjustment(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('orientation.jpg'));
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
$this->assertColor(1, 0, 254, 255, $image->pickColor(3, 3));
}
public function testReadWithoutRotationAdjustment(): void
{
$manager = new ImageManager(Driver::class, autoOrientation: false);
$image = $manager->decode($this->getTestResourcePath('orientation.jpg'));
$image = $manager->read($this->getTestResourcePath('orientation.jpg'));
$this->assertColor(250, 2, 3, 255, $image->pickColor(3, 3));
}
public function testReadAnimation(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('animation.gif'));
$image = $manager->read($this->getTestResourcePath('animation.gif'));
$this->assertTrue($image->isAnimated());
}
public function testReadAnimationDiscarded(): void
{
$manager = new ImageManager(Driver::class, decodeAnimation: false);
$image = $manager->decode($this->getTestResourcePath('animation.gif'));
$image = $manager->read($this->getTestResourcePath('animation.gif'));
$this->assertFalse($image->isAnimated());
}
public function testApplyBackgroundColor(): void
{
$manager = new ImageManager(Driver::class);
$image = $manager->decode($this->getTestResourcePath('blocks.png'));
$image = $manager->read($this->getTestResourcePath('blocks.png'));
$result = $image->background();
$this->assertColor(255, 255, 255, 255, $image->pickColor(530, 0));
$this->assertColor(255, 255, 255, 255, $result->pickColor(530, 0));
@@ -149,7 +149,7 @@ final class ImageManagerTestImagick extends BaseTestCase
public function testApplyBackgroundColorConfigured(): void
{
$manager = new ImageManager(Driver::class, backgroundColor: 'ff5500');
$image = $manager->decode($this->getTestResourcePath('blocks.png'));
$image = $manager->read($this->getTestResourcePath('blocks.png'));
$result = $image->background();
$this->assertColor(255, 85, 0, 255, $image->pickColor(530, 0));
$this->assertColor(255, 85, 0, 255, $result->pickColor(530, 0));