Conditions | 12 |
Paths | 18 |
Total Lines | 45 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
101 | private function getValidationValues($values, array $context = []): array |
||
102 | { |
||
103 | if (null === $values || empty($values)) { |
||
104 | /** |
||
105 | * @NOTE If you have NULL/empty here you probably have a config issue. This validator would normally |
||
106 | * require a UNIQUE value to be compared, empty string obviously will not work. |
||
107 | * |
||
108 | * SUGGESTION - Perhaps you need to have a not empty validator registered before this one |
||
109 | * with break_chain_on_failure = true? This will prevent the NULL from being passed here. |
||
110 | */ |
||
111 | $values = ''; |
||
112 | } elseif ($values instanceof EntityInterface) { |
||
113 | $values = $values->getId(); |
||
114 | } |
||
115 | |||
116 | if (is_scalar($values) && isset($this->fieldNames[0]) && 1 === count($this->fieldNames)) { |
||
117 | /** |
||
118 | * Here we are mapping the single scalar value to the single match field, casting the value to an array. |
||
119 | */ |
||
120 | $values = [ |
||
121 | $this->fieldNames[0] => $values, |
||
122 | ]; |
||
123 | } elseif ( |
||
124 | is_scalar($values) |
||
125 | && (count($this->fieldNames) > 1 |
||
126 | || (bool)$this->getOption('useContext') ?: true) |
||
127 | ) { |
||
128 | /** |
||
129 | * @note if we have a scalar value and more than one field in the match criteria then we have to use |
||
130 | * the context as the replacement. |
||
131 | */ |
||
132 | $values = $context; |
||
133 | } |
||
134 | |||
135 | if (! is_array($values)) { |
||
136 | throw new RuntimeException( |
||
137 | sprintf( |
||
138 | 'The \'values\' argument of type \'%s\' could not be resolved \'array\' in \'%s\'.', |
||
139 | gettype($values), |
||
140 | __METHOD__ |
||
141 | ) |
||
142 | ); |
||
143 | } |
||
144 | |||
145 | return $values; |
||
146 | } |
||
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