Skip to content

Commit

Permalink
add makeCustom method
Browse files Browse the repository at this point in the history
  • Loading branch information
abordage committed Jun 3, 2022
1 parent c1f0d10 commit 357cadb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/OpenGraphImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ public function make(string $text, string $preset = 'opengraph'): OpenGraphImage
return $this;
}

public function makeCustom(string $text, int $width = 1200, int $height = 630): OpenGraphImages
{
$this->imageWidth = $width;
$this->imageHeight = $height;

$this->createImage($text);

return $this;
}

public function get(): ?string
{
return $this->imageBlob;
Expand Down
18 changes: 18 additions & 0 deletions tests/OpenGraphImagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ public function testMake(string $text): void
}
}

/**
* @dataProvider textProvider
*/
public function testMakeCustom(string $text): void
{
$sizesCollection = [
[500, 500],
[600, 400],
];

foreach ($sizesCollection as $sizes) {
[$width, $height] = $sizes;
$result = $this->openGraphImages->makeCustom($text, $width, $height);
$this->assertInstanceOf(OpenGraphImages::class, $result);
$this->assertEquals('image/png', $this->getMimeTypeFromString($result->get()));
}
}

/**
* @dataProvider textProvider
*/
Expand Down

0 comments on commit 357cadb

Please sign in to comment.