Add captcha image generation functionality.
This commit is contained in:
24
app/Captcha/Dto/Sectors.php
Normal file
24
app/Captcha/Dto/Sectors.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Captcha\Dto;
|
||||
|
||||
final class Sectors
|
||||
{
|
||||
private array $points = [];
|
||||
|
||||
public function add(int|float $x, int|float $y, int|float $width, int|float $height): self
|
||||
{
|
||||
$this->points[] = new Sector((int) $x, (int) $y, (int) $width, (int) $height);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function random(): Sector
|
||||
{
|
||||
$key = array_rand($this->points);
|
||||
$sector = $this->points[$key];
|
||||
unset($this->points[$key]);
|
||||
|
||||
return $sector;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user