Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
72 | 3 | private function validateDate(string $date) |
|
73 | { |
||
74 | 3 | $re = '/(20\d{2})(\d{2})(\d{2})/mi'; |
|
75 | |||
76 | 3 | preg_match_all($re, $date, $matches, PREG_SET_ORDER, 0); |
|
77 | |||
78 | 3 | if (empty($matches)) { |
|
79 | 1 | throw WrongData::invalidValuesProvided('Format date to use YYYYMMDD to fetch sentiment data.'); |
|
80 | } |
||
81 | 2 | } |
|
82 | } |
||
83 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.