Conditions | 15 |
Paths | 18 |
Total Lines | 72 |
Code Lines | 57 |
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 |
||
84 | public static function setIndexes(Collection $collection, $indexes) |
||
85 | { |
||
86 | |||
87 | $collection->dropIndexes(); |
||
88 | |||
89 | foreach ($indexes as $index) { |
||
90 | $columns = $index['columns']; |
||
91 | $name = $index['name']; |
||
92 | $type = $index['type']; |
||
93 | |||
94 | foreach ($columns as $column) { |
||
95 | if ($column == '_id') { |
||
96 | continue; |
||
97 | } |
||
98 | |||
99 | switch ($type) { |
||
100 | |||
101 | case 'TEXT': |
||
102 | $indexType = 'text'; |
||
103 | break; |
||
104 | case 'INDEX': |
||
105 | $indexType = 1; |
||
106 | break; |
||
107 | case 'UNIQUE': |
||
108 | $indexType = 1; |
||
109 | $options['unique'] = true; |
||
110 | break; |
||
111 | case 'UNIQUE_DESC': |
||
112 | $indexType = -1; |
||
113 | $options['unique'] = true; |
||
114 | break; |
||
115 | case 'TTL': |
||
116 | $indexType = 1; |
||
117 | $options['expireAfterSeconds'] = 3600; |
||
118 | break; |
||
119 | case 'SPARSE': |
||
120 | $indexType = 1; |
||
121 | $options['sparse'] = true; |
||
122 | break; |
||
123 | case 'SPARSE_DESC': |
||
124 | $indexType = -1; |
||
125 | $options['sparse'] = true; |
||
126 | break; |
||
127 | case 'SPARSE_UNIQUE': |
||
128 | $indexType = 1; |
||
129 | $options['sparse'] = true; |
||
130 | $options['unique'] = true; |
||
131 | case 'SPARSE_UNIQUE_DESC': |
||
132 | $indexType = -1; |
||
133 | $options['sparse'] = true; |
||
134 | $options['unique'] = true; |
||
135 | break; |
||
136 | case 'ASC': |
||
137 | $indexType = 1; |
||
138 | break; |
||
139 | case 'DESC': |
||
140 | $indexType = -1; |
||
141 | break; |
||
142 | default: |
||
143 | $indexType = 1; |
||
144 | break; |
||
145 | } |
||
146 | |||
147 | $options['name'] = strtolower($collection->getCollectionName() . "_" . $column . "_" . $type); |
||
148 | |||
149 | $options['ns'] = $collection->getNamespace(); |
||
150 | |||
151 | $collection->createIndex([$column => $indexType], $options); |
||
152 | } |
||
153 | } |
||
154 | |||
155 | return true; |
||
156 | } |
||
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