We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 17 | class Date extends AbstractRule |
||
| 18 | { |
||
| 19 | public $format = null; |
||
| 20 | |||
| 21 | 64 | public function __construct($format = null) |
|
| 25 | |||
| 26 | 64 | public function validate($input) |
|
| 54 | |||
| 55 | 40 | private function isValidForFormatProvided($input) |
|
| 56 | { |
||
| 57 | 40 | $info = date_parse_from_format($this->format, $input); |
|
| 58 | 40 | if (!$this->isParsable($info)) { |
|
| 59 | 8 | return false; |
|
| 60 | } |
||
| 61 | |||
| 62 | 32 | if ($this->hasDateFormat()) { |
|
| 63 | 24 | return $this->hasValidDate($info); |
|
| 64 | } |
||
| 65 | |||
| 66 | 8 | return true; |
|
| 67 | } |
||
| 68 | |||
| 69 | 40 | private function isParsable(array $info) |
|
| 73 | |||
| 74 | 32 | private function hasDateFormat() |
|
| 78 | |||
| 79 | 24 | private function hasValidDate(array $info) |
|
| 87 | } |
||
| 88 |