1 | <?php |
||
9 | class CardExpirationDate implements Rule |
||
10 | { |
||
11 | const MSG_CARD_EXPIRATION_DATE_INVALID = 'validation.credit_card.card_expiation_date_invalid'; |
||
12 | const MSG_CARD_EXPIRATION_DATE_FORMAT_INVALID = 'validation.credit_card.card_expiation_date_format_invalid'; |
||
13 | |||
14 | protected $message; |
||
15 | |||
16 | /** |
||
17 | * Date field format. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $format; |
||
22 | |||
23 | /** |
||
24 | * CardExpirationDate constructor. |
||
25 | * |
||
26 | * @param string $format Date format |
||
27 | */ |
||
28 | 1 | public function __construct(string $format) |
|
33 | |||
34 | /** |
||
35 | * Determine if the validation rule passes. |
||
36 | * |
||
37 | * @param string $attribute |
||
38 | * @param mixed $value |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | 1 | public function passes($attribute, $value) |
|
56 | |||
57 | /** |
||
58 | * Get the validation error message. |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 1 | public function message() |
|
66 | } |
||
67 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.