| Conditions | 3 |
| Paths | 7 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 1 | public function passes($attribute, $value) |
|
| 42 | { |
||
| 43 | try { |
||
| 44 | // This can throw Invalid Date Exception if format is not supported. |
||
| 45 | 1 | Carbon::parse($value); |
|
| 46 | |||
| 47 | 1 | $date = Carbon::createFromFormat($this->format, $value); |
|
| 48 | |||
| 49 | 1 | return (new ExpirationDateValidator($date->year, $date->month)) |
|
| 50 | 1 | ->isValid(); |
|
| 51 | 1 | } catch (\InvalidArgumentException $ex) { |
|
| 52 | 1 | $this->message = static::MSG_CARD_EXPIRATION_DATE_FORMAT_INVALID; |
|
| 53 | |||
| 54 | 1 | return false; |
|
| 55 | 1 | } catch (\Exception $ex) { |
|
| 56 | 1 | $this->message = static::MSG_CARD_EXPIRATION_DATE_INVALID; |
|
| 57 | |||
| 58 | 1 | return false; |
|
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 72 |