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:
parent
c1cf5a1ae9
commit
81635b4efa
8
app/Captcha/Contracts/ImageManager.php
Normal file
8
app/Captcha/Contracts/ImageManager.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Captcha\Contracts;
|
||||||
|
|
||||||
|
interface ImageManager
|
||||||
|
{
|
||||||
|
public function createImage(int $width, int $height): Image;
|
||||||
|
}
|
18
app/Captcha/Images/ImageManager.php
Normal file
18
app/Captcha/Images/ImageManager.php
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user