| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 14 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 7 | 
| CRAP Score | 4 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 18 | 5 | public static function generate(DateInterval $duration = null, int $length = null): Token | |
| 19 |     { | ||
| 20 | 5 |         if (empty($length) || $length > 105) { | |
| 21 | 3 | $length = self::RANDOM_BYTES_LENGTH; | |
| 22 | } | ||
| 23 | |||
| 24 | 5 |         $duration = !empty($duration) ? $duration : new DateInterval(sprintf('P%1$sD', self::DURATION)); | |
| 25 | |||
| 26 | 5 | $random = random_bytes($length); | |
| 27 | |||
| 28 | 5 |         $token = base64_encode(sprintf('%1$s%2$s', $random, Uuid::uuid4()->toString())); | |
| 29 | |||
| 30 | 5 | return new Token($token, $duration); | |
| 31 | } | ||
| 32 | } | ||
| 33 |