This commit adds an ImageManager class that handles the creation of Image instances. It implements an ImageManagerContract, thereby adhering to set guidelines for the creation of captchas. The ImageManager class contains a createImage method capable of creating new instances of Image, allowing for increased flexibility and consistency in CAPTCHA image generation.

This commit is contained in:
Leonid Nikitin 2023-06-28 17:26:15 +06:00
parent c1cf5a1ae9
commit 81635b4efa
Signed by: kor-elf
GPG Key ID: 7DE8F80C5CEC2C0D
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace App\Captcha\Contracts;
interface ImageManager
{
public function createImage(int $width, int $height): Image;
}

View File

@ -0,0 +1,18 @@
<?php declare(strict_types=1);
namespace App\Captcha\Images;
use App\Captcha\Contracts\Image;
use App\Captcha\Contracts\ImageManager as ImageManagerContract;
final class ImageManager implements ImageManagerContract
{
public function __construct(
private readonly string $imageClassName
) { }
public function createImage(int $width, int $height): Image
{
return new $this->imageClassName($width, $height);
}
}