| Conditions | 2 |
| Paths | 10 |
| Total Lines | 66 |
| Code Lines | 19 |
| 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 |
||
| 73 | |||
| 74 | public function purchasingSuggestionPrintData(?People $provider, string $printType, string $deviceType) |
||
| 75 | { |
||
| 76 | $products = $this->getPurchasingSuggestion($provider); |
||
| 77 | |||
| 78 | $groupedByCompany = []; |
||
| 79 | foreach ($products as $product) { |
||
| 80 | $companyName = $product['company_name'] ; |
||
| 81 | if (!isset($groupedByCompany[$companyName])) { |
||
| 82 | $groupedByCompany[$companyName] = []; |
||
| 83 | } |
||
| 84 | $groupedByCompany[$companyName][] = $product; |
||
| 85 | } |
||
| 86 | |||
| 87 | $this->printService->addLine("", "", "-"); |
||
| 88 | $this->printService->addLine("SUGESTAO DE COMPRA", "", " "); |
||
| 89 | $this->printService->addLine("", "", "-"); |
||
| 90 | |||
| 91 | foreach ($groupedByCompany as $companyName => $items) { |
||
| 92 | $this->printService->addLine($companyName, "", " "); |
||
| 93 | $this->printService->addLine("", "", "-"); |
||
| 94 | $this->printService->addLine("Produto", "Necessario", " "); |
||
| 95 | $this->printService->addLine("", "", "-"); |
||
| 96 | |||
| 97 | foreach ($items as $item) { |
||
| 98 | $productName = substr($item['product_name'], 0, 20); |
||
| 99 | if (!empty($item['description'])) { |
||
| 100 | $productName .= " " . substr($item['description'], 0, 10); |
||
| 101 | } |
||
| 102 | if (!empty($item['unity'])) { |
||
| 103 | $productName .= " (" . $item['unity'] . ")"; |
||
| 104 | } |
||
| 105 | $needed = str_pad($item['needed'], 4, " ", STR_PAD_LEFT); |
||
| 106 | $this->printService->addLine($productName, $needed, " "); |
||
| 107 | } |
||
| 108 | |||
| 109 | $this->printService->addLine("", "", "-"); |
||
| 110 | } |
||
| 111 | |||
| 112 | return $this->printService->generatePrintData($printType, $deviceType); |
||
| 113 | } |
||
| 114 | } |
||
| 115 |
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