| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class SingleServerExtension implements Extension, HasMissingHandlerMessage |
||
| 12 | { |
||
| 13 | public const DEFAULT_TTL = 3600; |
||
| 14 | |||
| 15 | private $ttl; |
||
| 16 | private $lock; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param int $ttl Maximum expected lock duration in seconds |
||
| 20 | */ |
||
| 21 | 9 | public function __construct(int $ttl = self::DEFAULT_TTL) |
|
| 25 | 9 | } |
|
| 26 | |||
| 27 | 1 | public function __toString(): string |
|
| 30 | } |
||
| 31 | |||
| 32 | 4 | public function aquireLock(LockFactory $lockFactory, string $mutex, int $timestamp): bool |
|
| 33 | { |
||
| 34 | 4 | $mutex .= \date('Hi', $timestamp); |
|
| 35 | |||
| 36 | 4 | return $this->lock->aquire($lockFactory, $mutex, $this->ttl); |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | public function getMissingHandlerMessage(): string |
|
| 42 | } |
||
| 43 | } |
||
| 44 |