Skip to content

Commit

Permalink
Change method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 21, 2023
1 parent 019c333 commit 2acb4c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Drivers/Gd/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function add($source, float $delay = 1): self
return new Image($frames);
}

protected function newCore(int $width, int $height)
public function newCore(int $width, int $height)
{
$core = imagecreatetruecolor($width, $height);
$color = imagecolorallocatealpha($core, 0, 0, 0, 127);
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Imagick/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function add($source, float $delay = 1): self
return new Image($animation->imagick);
}

protected function newCore(int $width, int $height)
public function newCore(int $width, int $height)
{
$imagick = new Imagick();
$imagick->newImage($width, $height, new ImagickPixel('rgba(0, 0, 0, 0)'), 'png');
Expand Down
8 changes: 8 additions & 0 deletions src/Interfaces/FactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ public function newImage(int $width, int $height): ImageInterface;
* @return ImageInterface
*/
public function newAnimation(callable $callback): ImageInterface;

/**
* Create new driver specific core image object
*
* @param int $width
* @param int $height
*/
public function newCore(int $width, int $height);
}
8 changes: 8 additions & 0 deletions tests/Drivers/Gd/ImageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Intervention\Image\Tests\Drivers\Gd;

use GdImage;
use Intervention\Image\Drivers\Gd\Image;
use Intervention\Image\Drivers\Gd\ImageFactory;
use Intervention\Image\Tests\TestCase;
Expand Down Expand Up @@ -29,4 +30,11 @@ public function testNewAnimation(): void
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(2, $image->count());
}

public function testNewCore(): void
{
$factory = new ImageFactory();
$core = $factory->newCore(3, 2);
$this->assertInstanceOf(GdImage::class, $core);
}
}

0 comments on commit 2acb4c5

Please sign in to comment.