Add error badge rendering (#3)

This commit is contained in:
Anton Komarev
2020-07-12 18:48:32 +03:00
committed by GitHub
parent e4f24b04f7
commit c2a6fd9eea
6 changed files with 108 additions and 21 deletions

View File

@@ -17,20 +17,20 @@ use Contracts\Komarev\GitHubProfileViewsCounter\InvalidPathException;
final class CounterImageRendererService
{
private string $sourceImagePath;
private string $counterBadgePath;
public function __construct(string $sourceImagePath)
public function __construct(string $counterBadgePath)
{
if (!file_exists($sourceImagePath)) {
throw new InvalidPathException('Counter source image not found');
if (!file_exists($counterBadgePath)) {
throw new InvalidPathException('Counter badge image not found');
}
$this->sourceImagePath = $sourceImagePath;
$this->counterBadgePath = $counterBadgePath;
}
public function getImageWithCount(int $count): string
{
$counterImage = file_get_contents($this->sourceImagePath);
$counterImage = file_get_contents($this->counterBadgePath);
return $this->replaceImagePlaceholders($counterImage, $count);
}