| Conditions | 3 |
| Paths | 9 |
| Total Lines | 121 |
| Code Lines | 18 |
| 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 |
||
| 165 | public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null ) |
||
| 166 | { |
||
| 167 | $map = []; |
||
| 168 | $context = $this->getContext(); |
||
| 169 | |||
| 170 | $dbm = $context->getDatabaseManager(); |
||
| 171 | $dbname = $this->getResourceName(); |
||
| 172 | $conn = $dbm->acquire( $dbname ); |
||
| 173 | |||
| 174 | try |
||
| 175 | { |
||
| 176 | $required = array( 'customer.group' ); |
||
| 177 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL; |
||
| 178 | |||
| 179 | /** mshop/customer/manager/group/typo3/search |
||
| 180 | * Retrieves the records matched by the given criteria in the database |
||
| 181 | * |
||
| 182 | * Fetches the records matched by the given criteria from the customer |
||
| 183 | * database. The records must be from one of the sites that are |
||
| 184 | * configured via the context item. If the current site is part of |
||
| 185 | * a tree of sites, the SELECT statement can retrieve all records |
||
| 186 | * from the current site and the complete sub-tree of sites. |
||
| 187 | * |
||
| 188 | * As the records can normally be limited by criteria from sub-managers, |
||
| 189 | * their tables must be joined in the SQL context. This is done by |
||
| 190 | * using the "internaldeps" property from the definition of the ID |
||
| 191 | * column of the sub-managers. These internal dependencies specify |
||
| 192 | * the JOIN between the tables and the used columns for joining. The |
||
| 193 | * ":joins" placeholder is then replaced by the JOIN strings from |
||
| 194 | * the sub-managers. |
||
| 195 | * |
||
| 196 | * To limit the records matched, conditions can be added to the given |
||
| 197 | * criteria object. It can contain comparisons like column names that |
||
| 198 | * must match specific values which can be combined by AND, OR or NOT |
||
| 199 | * operators. The resulting string of SQL conditions replaces the |
||
| 200 | * ":cond" placeholder before the statement is sent to the database |
||
| 201 | * server. |
||
| 202 | * |
||
| 203 | * If the records that are retrieved should be ordered by one or more |
||
| 204 | * columns, the generated string of column / sort direction pairs |
||
| 205 | * replaces the ":order" placeholder. In case no ordering is required, |
||
| 206 | * the complete ORDER BY part including the "\/*-orderby*\/...\/*orderby-*\/" |
||
| 207 | * markers is removed to speed up retrieving the records. Columns of |
||
| 208 | * sub-managers can also be used for ordering the result set but then |
||
| 209 | * no index can be used. |
||
| 210 | * |
||
| 211 | * The number of returned records can be limited and can start at any |
||
| 212 | * number between the begining and the end of the result set. For that |
||
| 213 | * the ":size" and ":start" placeholders are replaced by the |
||
| 214 | * corresponding values from the criteria object. The default values |
||
| 215 | * are 0 for the start and 100 for the size value. |
||
| 216 | * |
||
| 217 | * The SQL statement should conform to the ANSI standard to be |
||
| 218 | * compatible with most relational database systems. This also |
||
| 219 | * includes using double quotes for table and column names. |
||
| 220 | * |
||
| 221 | * @param string SQL statement for searching items |
||
| 222 | * @since 2015.08 |
||
| 223 | * @category Developer |
||
| 224 | * @see mshop/customer/manager/group/typo3/count |
||
| 225 | */ |
||
| 226 | $cfgPathSearch = 'mshop/customer/manager/group/typo3/search'; |
||
| 227 | |||
| 228 | /** mshop/customer/manager/group/typo3/count |
||
| 229 | * Counts the number of records matched by the given criteria in the database |
||
| 230 | * |
||
| 231 | * Counts all records matched by the given criteria from the customer |
||
| 232 | * database. The records must be from one of the sites that are |
||
| 233 | * configured via the context item. If the current site is part of |
||
| 234 | * a tree of sites, the statement can count all records from the |
||
| 235 | * current site and the complete sub-tree of sites. |
||
| 236 | * |
||
| 237 | * As the records can normally be limited by criteria from sub-managers, |
||
| 238 | * their tables must be joined in the SQL context. This is done by |
||
| 239 | * using the "internaldeps" property from the definition of the ID |
||
| 240 | * column of the sub-managers. These internal dependencies specify |
||
| 241 | * the JOIN between the tables and the used columns for joining. The |
||
| 242 | * ":joins" placeholder is then replaced by the JOIN strings from |
||
| 243 | * the sub-managers. |
||
| 244 | * |
||
| 245 | * To limit the records matched, conditions can be added to the given |
||
| 246 | * criteria object. It can contain comparisons like column names that |
||
| 247 | * must match specific values which can be combined by AND, OR or NOT |
||
| 248 | * operators. The resulting string of SQL conditions replaces the |
||
| 249 | * ":cond" placeholder before the statement is sent to the database |
||
| 250 | * server. |
||
| 251 | * |
||
| 252 | * Both, the strings for ":joins" and for ":cond" are the same as for |
||
| 253 | * the "search" SQL statement. |
||
| 254 | * |
||
| 255 | * Contrary to the "search" statement, it doesn't return any records |
||
| 256 | * but instead the number of records that have been found. As counting |
||
| 257 | * thousands of records can be a long running task, the maximum number |
||
| 258 | * of counted records is limited for performance reasons. |
||
| 259 | * |
||
| 260 | * The SQL statement should conform to the ANSI standard to be |
||
| 261 | * compatible with most relational database systems. This also |
||
| 262 | * includes using double quotes for table and column names. |
||
| 263 | * |
||
| 264 | * @param string SQL statement for counting items |
||
| 265 | * @since 2015.08 |
||
| 266 | * @category Developer |
||
| 267 | * @see mshop/customer/manager/group/typo3/search |
||
| 268 | */ |
||
| 269 | $cfgPathCount = 'mshop/customer/manager/group/typo3/count'; |
||
| 270 | |||
| 271 | $results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level ); |
||
| 272 | |||
| 273 | while( ( $row = $results->fetch() ) !== false ) { |
||
| 274 | $map[$row['customer.group.id']] = $this->createItemBase( $row ); |
||
| 275 | } |
||
| 276 | |||
| 277 | $dbm->release( $conn, $dbname ); |
||
| 278 | } |
||
| 279 | catch( \Exception $e ) |
||
| 280 | { |
||
| 281 | $dbm->release( $conn, $dbname ); |
||
| 282 | throw $e; |
||
| 283 | } |
||
| 284 | |||
| 285 | return $map; |
||
| 286 | } |
||
| 310 |
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