| Conditions | 9 |
| Paths | 3 |
| Total Lines | 55 |
| Code Lines | 34 |
| 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 |
||
| 53 | public function generatePrintData(Order $order, string $printType, string $deviceType) |
||
| 54 | { |
||
| 55 | |||
| 56 | if ($printType === 'pos') { |
||
| 57 | $this->addLine("PEDIDO #" . $order->getId()); |
||
| 58 | $this->addLine($order->getOrderDate()->format('d/m/Y H:i')); |
||
| 59 | $client = $order->getClient(); |
||
| 60 | $this->addLine(($client !== null ? $client->getName() : 'Não informado')); |
||
| 61 | $this->addLine(number_format($order->getPrice(), 2, ',', '.')); |
||
| 62 | $this->addLine("", "", "-"); |
||
| 63 | |||
| 64 | $queues = $this->getQueues($order); |
||
| 65 | |||
| 66 | |||
| 67 | foreach ($queues as $queueName => $products) { |
||
| 68 | $this->addLine(strtoupper($queueName) . ":"); |
||
| 69 | foreach ($products as $orderProduct) { |
||
| 70 | $product = $orderProduct->getProduct(); |
||
| 71 | $unit = $product->getProductUnit()->getProductUnit(); |
||
| 72 | $quantity = $orderProduct->getQuantity(); |
||
| 73 | |||
| 74 | $this->addLine( |
||
| 75 | "- " . $product->getProduct() . " (" . $quantity . " " . $unit . ")", |
||
| 76 | " R$ " . number_format($product->getPrice() * $quantity, 2, ',', '.'), |
||
| 77 | '.' |
||
| 78 | ); |
||
| 79 | |||
| 80 | |||
| 81 | if ($product->getType() === 'custom') { |
||
| 82 | $this->addLine(" Personalizações:"); |
||
| 83 | $productGroupProducts = $this->entityManager->getRepository(ProductGroupProduct::class) |
||
| 84 | ->findBy(['product' => $product->getId()]); |
||
| 85 | |||
| 86 | foreach ($productGroupProducts as $pgp) { |
||
| 87 | $childProduct = $pgp->getProductChild(); |
||
| 88 | if ($childProduct) |
||
| 89 | $this->addLine(" - " . $childProduct->getProduct() . " (" . $pgp->getQuantity() . " " . $childProduct->getProductUnit()->getProductUnit() . ")"); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | $this->addLine('', '', ' '); |
||
| 94 | } |
||
| 95 | |||
| 96 | $this->addLine('', '', '-'); |
||
| 97 | |||
| 98 | |||
| 99 | if ($deviceType === 'cielo') |
||
| 100 | return [ |
||
| 101 | "operation" => "PRINT_TEXT", |
||
| 102 | "styles" => [[]], |
||
| 103 | "value" => [$this->text] |
||
| 104 | ]; |
||
| 105 | } |
||
| 106 | |||
| 107 | throw new Exception("Unsupported print type", 1); |
||
| 108 | } |
||
| 110 |
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