| Total Complexity | 3 | 
| Total Lines | 39 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 15 | final class Expiration  | 
            ||
| 16 | { | 
            ||
| 17 | /** @var string The expiration unit. */  | 
            ||
| 18 | private string $expiration;  | 
            ||
| 19 | |||
| 20 | /** The valid expiration units. */  | 
            ||
| 21 | private const VALID_UNITS = [  | 
            ||
| 22 | 'second', 'seconds',  | 
            ||
| 23 | 'minute', 'minutes',  | 
            ||
| 24 | 'hour', 'hours',  | 
            ||
| 25 | 'day', 'days',  | 
            ||
| 26 | 'week', 'weeks',  | 
            ||
| 27 | 'month', 'months',  | 
            ||
| 28 | 'year', 'years',  | 
            ||
| 29 | ];  | 
            ||
| 30 | |||
| 31 | /**  | 
            ||
| 32 | * Create a new Expiration instance.  | 
            ||
| 33 | *  | 
            ||
| 34 | * @param string $expiration The expiration unit.  | 
            ||
| 35 | * @throws InvalidParamException If the provided expiration unit is invalid.  | 
            ||
| 36 | */  | 
            ||
| 37 | public function __construct(string $expiration)  | 
            ||
| 38 |     { | 
            ||
| 39 |         if (!in_array($expiration, self::VALID_UNITS)) { | 
            ||
| 40 |             throw new InvalidParamException("Invalid expiration unit: '$expiration'."); | 
            ||
| 41 | }  | 
            ||
| 42 | |||
| 43 | $this->expiration = $expiration;  | 
            ||
| 44 | }  | 
            ||
| 45 | |||
| 46 | /**  | 
            ||
| 47 | * Get the string representation of the expiration unit.  | 
            ||
| 48 | *  | 
            ||
| 49 | * @return string The expiration unit.  | 
            ||
| 50 | */  | 
            ||
| 51 | public function __toString(): string  | 
            ||
| 54 | }  | 
            ||
| 55 | }  |