We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | final class Time extends AbstractRule |
||
| 28 | { |
||
| 29 | public const DEFAULT_FORMAT = 'H:i:s'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | private $format; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Initializes the rule. |
||
| 38 | * |
||
| 39 | * @param string $format |
||
| 40 | * |
||
| 41 | * @throws ComponentException |
||
| 42 | */ |
||
| 43 | 3 | public function __construct(string $format = 'H:i:s') |
|
| 44 | { |
||
| 45 | 3 | if (!preg_match('/^[gGhHisuvaA\W]+$/', $format)) { |
|
| 46 | 2 | throw new ComponentException(sprintf('"%s" is not a valid date format', $format)); |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | $this->format = $format; |
|
| 50 | 1 | } |
|
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | 14 | public function validate($input): bool |
|
| 64 | } |
||
| 65 | } |
||
| 66 |