| Conditions | 12 |
| Paths | 109 |
| Total Lines | 61 |
| 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 |
||
| 51 | public function store(array $headers, array $groupMySQL, bool $addToPartRepair = true): array |
||
| 52 | { |
||
| 53 | if (empty($headers)) { |
||
| 54 | return []; |
||
| 55 | } |
||
| 56 | |||
| 57 | // Reset all handlers |
||
| 58 | $this->collectionHandler->reset(); |
||
| 59 | $this->binaryHandler->reset(); |
||
| 60 | $this->partHandler->reset(); |
||
| 61 | $this->partHandler->setAddToPartRepair($addToPartRepair); |
||
| 62 | $this->failedInserts = []; |
||
| 63 | |||
| 64 | // Create transaction |
||
| 65 | $transaction = new HeaderStorageTransaction( |
||
| 66 | $this->collectionHandler, |
||
| 67 | $this->binaryHandler, |
||
| 68 | $this->partHandler |
||
| 69 | ); |
||
| 70 | |||
| 71 | $transaction->begin(); |
||
| 72 | |||
| 73 | // Process each header |
||
| 74 | foreach ($headers as $header) { |
||
| 75 | if (! $this->processHeader($header, $groupMySQL, $transaction)) { |
||
| 76 | if ($addToPartRepair && isset($header['Number'])) { |
||
| 77 | $this->failedInserts[] = $header['Number']; |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | // Flush remaining parts |
||
| 83 | if ($this->partHandler->hasPending()) { |
||
| 84 | if (! $this->partHandler->flush()) { |
||
| 85 | $transaction->markError(); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | // Flush binary aggregate updates |
||
| 90 | if (! $transaction->hasErrors()) { |
||
| 91 | if (! $this->binaryHandler->flushUpdates($this->config->binariesUpdateChunkSize)) { |
||
| 92 | $transaction->markError(); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | // Finish transaction |
||
| 97 | if (! $transaction->finish()) { |
||
| 98 | // All failed |
||
| 99 | if ($addToPartRepair) { |
||
| 100 | return array_unique(array_merge( |
||
| 101 | $this->failedInserts, |
||
| 102 | $this->partHandler->getFailedNumbers() |
||
| 103 | )); |
||
| 104 | } |
||
| 105 | |||
| 106 | return []; |
||
| 107 | } |
||
| 108 | |||
| 109 | return array_unique(array_merge( |
||
| 110 | $this->failedInserts, |
||
| 111 | $this->partHandler->getFailedNumbers() |
||
| 112 | )); |
||
| 175 |
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