25 lines
525 B
PHP
25 lines
525 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Attributes;
|
||
|
|
|
||
|
|
use Webmozart\Assert\Assert;
|
||
|
|
|
||
|
|
#[\Attribute(\Attribute::TARGET_CLASS)]
|
||
|
|
final readonly class Locked
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public int $ttlSeconds = 30,
|
||
|
|
public int $waitSeconds = 10,
|
||
|
|
public ?string $key = null,
|
||
|
|
) {
|
||
|
|
Assert::greaterThan($this->ttlSeconds, 0);
|
||
|
|
Assert::greaterThanEq($this->waitSeconds, 0);
|
||
|
|
|
||
|
|
if ($this->key !== null) {
|
||
|
|
Assert::stringNotEmpty(trim($this->key));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|