Skip to content

Commit

Permalink
Rename GD decoder static constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
robgridley committed Apr 2, 2018
1 parent b16dc8c commit de8557c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use Zebra\Zpl\Image;
use Zebra\Zpl\Builder;
use Zebra\Zpl\GdDecoder;

$image = new Image(GdDecoder::createFromPath('example.png'));
$decoder = GdDecoder::fromPath('example.png');
$image = new Image($decoder);

$zpl = new Builder();
$zpl->fo(50, 50)->gf($image)->fs();
Expand Down
4 changes: 2 additions & 2 deletions spec/Zpl/ImageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ImageSpec extends ObjectBehavior
{
function let()
{
$decoder = GdDecoder::createFromPath(__DIR__ . '/../test_150.png');
$decoder = GdDecoder::fromPath(__DIR__ . '/../test_150.png');
$this->beConstructedWith($decoder);
}

Expand All @@ -21,7 +21,7 @@ function it_converts_images_to_compressed_ascii_hexadecimal_bitmaps()

function it_converts_large_images_to_compressed_ascii_hexadecimal_bitmaps()
{
$decoder = GdDecoder::createFromPath(__DIR__ . '/../test_1000.png');
$decoder = GdDecoder::fromPath(__DIR__ . '/../test_1000.png');
$this->beConstructedWith($decoder);

$this->toAscii()->shouldReturn(file_get_contents(__DIR__ . '/../test_1000.txt'));
Expand Down
8 changes: 4 additions & 4 deletions src/Zpl/GdDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function isGdResource($image): bool
* @param resource $image
* @return GdDecoder
*/
public static function createFromResource($image): self
public static function fromResource($image): self
{
return new static($image);
}
Expand All @@ -75,9 +75,9 @@ public static function createFromResource($image): self
* @param string $path
* @return GdDecoder
*/
public static function createFromPath(string $path): self
public static function fromPath(string $path): self
{
return static::createFromString(file_get_contents($path));
return static::fromString(file_get_contents($path));
}

/**
Expand All @@ -86,7 +86,7 @@ public static function createFromPath(string $path): self
* @param string $data
* @return GdDecoder
*/
public static function createFromString(string $data): self
public static function fromString(string $data): self
{
if (false === $image = imagecreatefromstring($data)) {
throw new InvalidArgumentException('Could not read image');
Expand Down

0 comments on commit de8557c

Please sign in to comment.