| Conditions | 13 |
| Paths | 85 |
| Total Lines | 48 |
| Code Lines | 31 |
| 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 |
||
| 18 | public function batchInsert(string $table, array $columns, iterable|Generator $rows, array &$params = []): string |
||
| 19 | { |
||
| 20 | if (empty($rows)) { |
||
| 21 | return ''; |
||
| 22 | } |
||
| 23 | |||
| 24 | if (($tableSchema = $this->queryBuilder->schema()->getTableSchema($table)) !== null) { |
||
| 25 | $columnSchemas = $tableSchema->getColumns(); |
||
| 26 | } else { |
||
| 27 | $columnSchemas = []; |
||
| 28 | } |
||
| 29 | |||
| 30 | $values = []; |
||
| 31 | |||
| 32 | foreach ($rows as $row) { |
||
| 33 | $vs = []; |
||
| 34 | foreach ($row as $i => $value) { |
||
| 35 | if (isset($columns[$i], $columnSchemas[$columns[$i]])) { |
||
| 36 | $value = $columnSchemas[$columns[$i]]->dbTypecast($value); |
||
| 37 | } |
||
| 38 | if (is_string($value)) { |
||
| 39 | $value = $this->queryBuilder->quoter()->quoteValue($value); |
||
| 40 | } elseif (is_float($value)) { |
||
| 41 | /* ensure type cast always has . as decimal separator in all locales */ |
||
| 42 | $value = NumericHelper::normalize((string) $value); |
||
| 43 | } elseif ($value === false) { |
||
| 44 | $value = 0; |
||
| 45 | } elseif ($value === null) { |
||
| 46 | $value = 'NULL'; |
||
| 47 | } elseif ($value instanceof ExpressionInterface) { |
||
| 48 | $value = $this->queryBuilder->buildExpression($value, $params); |
||
| 49 | } |
||
| 50 | $vs[] = $value; |
||
| 51 | } |
||
| 52 | $values[] = '(' . implode(', ', $vs) . ')'; |
||
| 53 | } |
||
| 54 | |||
| 55 | if (empty($values)) { |
||
| 56 | return ''; |
||
| 57 | } |
||
| 58 | |||
| 59 | foreach ($columns as $i => $name) { |
||
| 60 | $columns[$i] = $this->queryBuilder->quoter()->quoteColumnName($name); |
||
| 61 | } |
||
| 62 | |||
| 63 | return 'INSERT INTO ' |
||
| 64 | . $this->queryBuilder->quoter()->quoteTableName($table) |
||
| 65 | . ' (' . implode(', ', $columns) . ') VALUES ' . implode(', ', $values); |
||
| 66 | } |
||
| 118 |
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