mirror of
https://github.com/Intervention/image.git
synced 2025-01-16 19:58:14 +01:00
Optimize code
This commit is contained in:
parent
2763c23bcd
commit
60f3840b67
@ -26,10 +26,6 @@ abstract class AbstractDecoder extends SpecializableDecoder implements Specializ
|
||||
throw new DecoderException('Unable to detect media (MIME) from data in file path.');
|
||||
}
|
||||
|
||||
if (!array_key_exists('mime', $info)) {
|
||||
throw new DecoderException('Unable to detect media (MIME) from data in file path.');
|
||||
}
|
||||
|
||||
return MediaType::from($info['mime']);
|
||||
}
|
||||
|
||||
@ -48,10 +44,6 @@ abstract class AbstractDecoder extends SpecializableDecoder implements Specializ
|
||||
throw new DecoderException('Unable to detect media (MIME) from binary data.');
|
||||
}
|
||||
|
||||
if (!array_key_exists('mime', $info)) {
|
||||
throw new DecoderException('Unable to detect media (MIME) from binary data.');
|
||||
}
|
||||
|
||||
return MediaType::from($info['mime']);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ namespace Intervention\Image\Drivers\Gd;
|
||||
|
||||
use GdImage;
|
||||
use Intervention\Image\Exceptions\ColorException;
|
||||
use Intervention\Image\Exceptions\InputException;
|
||||
use Intervention\Image\Geometry\Rectangle;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Interfaces\DriverInterface;
|
||||
@ -112,9 +113,14 @@ class Frame implements FrameInterface
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see FrameInterface::setDispose()
|
||||
* @throws InputException
|
||||
*/
|
||||
public function setDispose(int $dispose): FrameInterface
|
||||
{
|
||||
if (!in_array($dispose, [0, 1, 2, 3])) {
|
||||
throw new InputException('Value for argument $dispose must be 0, 1, 2 or 3.');
|
||||
}
|
||||
|
||||
$this->dispose = $dispose;
|
||||
|
||||
return $this;
|
||||
|
@ -7,6 +7,7 @@ namespace Intervention\Image\Drivers\Imagick;
|
||||
use Imagick;
|
||||
use ImagickException;
|
||||
use ImagickPixel;
|
||||
use Intervention\Image\Exceptions\InputException;
|
||||
use Intervention\Image\Geometry\Rectangle;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Interfaces\DriverInterface;
|
||||
@ -111,9 +112,14 @@ class Frame implements FrameInterface
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see DriverInterface::setDispose()
|
||||
* @throws InputException
|
||||
*/
|
||||
public function setDispose(int $dispose): FrameInterface
|
||||
{
|
||||
if (!in_array($dispose, [0, 1, 2, 3])) {
|
||||
throw new InputException('Value for argument $dispose must be 0, 1, 2 or 3.');
|
||||
}
|
||||
|
||||
$this->native->setImageDispose($dispose);
|
||||
|
||||
return $this;
|
||||
|
@ -66,9 +66,9 @@ final class FrameTest extends BaseTestCase
|
||||
$frame = $this->getTestFrame();
|
||||
$this->assertEquals(1, $frame->dispose());
|
||||
|
||||
$result = $frame->setDispose(100);
|
||||
$result = $frame->setDispose(3);
|
||||
$this->assertInstanceOf(Frame::class, $result);
|
||||
$this->assertEquals(100, $frame->dispose());
|
||||
$this->assertEquals(3, $frame->dispose());
|
||||
}
|
||||
|
||||
public function testSetGetOffsetLeft(): void
|
||||
|
@ -23,7 +23,7 @@ final class FrameTest extends BaseTestCase
|
||||
$imagick = new Imagick();
|
||||
$imagick->newImage(3, 2, new ImagickPixel('red'), 'png');
|
||||
$imagick->setImageDelay(125); // 1.25 seconds
|
||||
$imagick->setImageDispose(5);
|
||||
$imagick->setImageDispose(0);
|
||||
$imagick->setImagePage(3, 2, 8, 9);
|
||||
|
||||
return new Frame($imagick);
|
||||
@ -55,11 +55,11 @@ final class FrameTest extends BaseTestCase
|
||||
public function testSetGetDispose(): void
|
||||
{
|
||||
$frame = $this->getTestFrame();
|
||||
$this->assertEquals(5, $frame->dispose());
|
||||
$this->assertEquals(0, $frame->dispose());
|
||||
|
||||
$result = $frame->setDispose(100);
|
||||
$result = $frame->setDispose(3);
|
||||
$this->assertInstanceOf(Frame::class, $result);
|
||||
$this->assertEquals(100, $frame->dispose());
|
||||
$this->assertEquals(3, $frame->dispose());
|
||||
}
|
||||
|
||||
public function testSetGetOffsetLeft(): void
|
||||
|
Loading…
x
Reference in New Issue
Block a user