| Total Complexity | 45 |
| Total Lines | 148 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Index often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Index, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | class Index |
||
| 9 | { |
||
| 10 | public static function getIndexes(Collection $collection) |
||
| 11 | { |
||
| 12 | $listIndexes = $collection->listIndexes(); |
||
| 13 | $indexes = []; |
||
| 14 | foreach ($listIndexes as $index) { |
||
| 15 | $indexes[] = [ |
||
| 16 | "name" => $index->getName(), |
||
| 17 | "oldName" => $index->getName(), |
||
| 18 | "columns" => array_keys($index->getKey()), |
||
| 19 | "type" => static::getType($index), |
||
| 20 | "isPrimary" => false, |
||
| 21 | "isUnique" => $index->isUnique(), |
||
| 22 | "isComposite" => (count($index->getKey()) > 1) ? true : false, |
||
| 23 | "flags" => [], |
||
| 24 | "options" => [], |
||
| 25 | "namespace" => $index->getNamespace(), |
||
| 26 | ]; |
||
| 27 | } |
||
| 28 | |||
| 29 | return $indexes; |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function getType(IndexInfo $index) |
||
| 66 | } |
||
| 67 | |||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | protected static function checkDescending($index) |
||
| 82 | } |
||
| 83 | |||
| 84 | public static function setIndexes(Collection $collection, $indexes) |
||
| 156 | } |
||
| 157 | } |
||
| 158 |
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