Conditions | 5 |
Paths | 5 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 5.0342 |
Changes | 0 |
1 | <?php |
||
41 | 27 | View Code Duplication | protected function validateSeconds(string $seconds): bool |
|
|||
42 | { |
||
43 | 27 | $precision = strlen(substr(strrchr($seconds, '.'), 1)); |
|
44 | |||
45 | 27 | if ($precision > 6) { |
|
46 | 6 | return false; |
|
47 | } |
||
48 | |||
49 | 21 | $seconds = (float) $seconds; |
|
50 | |||
51 | 21 | return $seconds >= 0 && $seconds < 60; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Validates that the string can represent minutes. |
||
56 | * |
||
57 | * @param string $minutes |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | 27 | protected function validateMinutes(string $minutes): bool |
|
62 | { |
||
63 | 27 | $minutes = (int) $minutes; |
|
64 | |||
65 | 27 | return $minutes >= 0 && $minutes < 60; |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * Validates tha the string can represent hours. |
||
70 | * |
||
71 | * @param string $hours |
||
72 | * |
||
73 | * @return bool |
||
82 |
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.