| Conditions | 13 |
| Paths | 1152 |
| Total Lines | 70 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 77 | public static function create(array $date = []) |
||
| 78 | { |
||
| 79 | if (!array_key_exists('day', $date)) |
||
| 80 | $date["day"] = self::TODAY; |
||
| 81 | |||
| 82 | if (!array_key_exists('month', $date)) |
||
| 83 | $date["month"] = self::THIS_MONTH; |
||
| 84 | |||
| 85 | if (!array_key_exists('year', $date)) |
||
| 86 | $date["year"] = self::THIS_YEAR; |
||
| 87 | |||
| 88 | switch ($date['year']) |
||
| 89 | { |
||
| 90 | case self::THIS_YEAR: |
||
| 91 | $year = (int) date('Y'); |
||
| 92 | break; |
||
| 93 | |||
| 94 | case self::LAST_YEAR: |
||
| 95 | $year = ((int) date('Y'))- 1; |
||
| 96 | break; |
||
| 97 | |||
| 98 | default: |
||
| 99 | $year = (int) $date["year"]; |
||
| 100 | break; |
||
| 101 | } |
||
| 102 | |||
| 103 | $month = ($date['month'] == self::THIS_MONTH) |
||
| 104 | ? self::MONTHS[(int) date('m')] |
||
| 105 | : ( |
||
| 106 | ($date['month'] == self::LAST_MONTH) |
||
| 107 | ? '-1 month' |
||
| 108 | : self::getMonth($date['month']) |
||
| 109 | ) |
||
| 110 | ; |
||
| 111 | |||
| 112 | switch ($date['day']) |
||
| 113 | { |
||
| 114 | case self::TODAY: |
||
| 115 | $day = (int) date('d'); |
||
| 116 | break; |
||
| 117 | |||
| 118 | case self::FIRST_DAY: |
||
| 119 | $day = 'first day of'; |
||
| 120 | break; |
||
| 121 | |||
| 122 | case self::LAST_DAY: |
||
| 123 | $day = 'last day of'; |
||
| 124 | break; |
||
| 125 | |||
| 126 | default: |
||
| 127 | $day = (int) $date["day"]; |
||
| 128 | break; |
||
| 129 | } |
||
| 130 | |||
| 131 | if (is_string($day)) |
||
| 132 | $d = new \DateTime("$day $month $year"); |
||
| 133 | else |
||
| 134 | { |
||
| 135 | if (in_array($month, self::MONTHS)) |
||
| 136 | $d = new \DateTime("first day of $month $year"); |
||
| 137 | else |
||
| 138 | { |
||
| 139 | $d = new \DateTime("first day of $month"); |
||
| 140 | $d->setDate($year, $d->format('m'), $d->format('d')); |
||
| 141 | } |
||
| 142 | |||
| 143 | $d->add(new \DateInterval('P'.($day - 1).'D')); |
||
| 144 | } |
||
| 145 | |||
| 146 | return $d; |
||
| 147 | } |
||
| 148 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths