| Conditions | 17 |
| Paths | 400 |
| Total Lines | 74 |
| Code Lines | 40 |
| 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 | protected static function setHeader(ModelClass $model, TicketPrinter $printer, string $title): void |
||
| 54 | { |
||
| 55 | if ($printer->print_stored_logo) { |
||
| 56 | static::$escpos->setJustification(Printer::JUSTIFY_CENTER); |
||
| 57 | // imprimimos el logotipo almacenado en la impresora |
||
| 58 | static::$connector->write("\x1Cp\x01\x00\x00"); |
||
| 59 | static::$escpos->feed(); |
||
| 60 | } |
||
| 61 | |||
| 62 | // obtenemos los datos de la empresa |
||
| 63 | $company = $model->getCompany(); |
||
| 64 | |||
| 65 | // establecemos el tamaño de la fuente |
||
| 66 | static::$escpos->setTextSize($printer->title_font_size, $printer->title_font_size); |
||
| 67 | |||
| 68 | // imprimimos el nombre corto de la empresa |
||
| 69 | if ($printer->print_comp_shortname) { |
||
| 70 | static::$escpos->text(static::sanitize($company->nombrecorto) . "\n"); |
||
| 71 | static::$escpos->setTextSize($printer->head_font_size, $printer->head_font_size); |
||
| 72 | |||
| 73 | // imprimimos el nombre de la empresa |
||
| 74 | static::$escpos->text(static::sanitize($company->nombre) . "\n"); |
||
| 75 | } else { |
||
| 76 | // imprimimos el nombre de la empresa |
||
| 77 | static::$escpos->text(static::sanitize($company->nombre) . "\n"); |
||
| 78 | static::$escpos->setTextSize($printer->head_font_size, $printer->head_font_size); |
||
| 79 | } |
||
| 80 | |||
| 81 | static::$escpos->setJustification(); |
||
| 82 | |||
| 83 | // imprimimos la dirección de la empresa |
||
| 84 | static::$escpos->text(static::sanitize($company->direccion) . "\n"); |
||
| 85 | static::$escpos->text(static::sanitize("CP: " . $company->codpostal . ', ' . $company->ciudad) . "\n"); |
||
| 86 | static::$escpos->text(static::sanitize($company->tipoidfiscal . ': ' . $company->cifnif) . "\n\n"); |
||
| 87 | |||
| 88 | if ($printer->print_comp_tlf) { |
||
| 89 | if (false === empty($company->telefono1) && false === empty($company->telefono2)) { |
||
| 90 | static::$escpos->text(static::sanitize($company->telefono1 . ' / ' . $company->telefono2) . "\n"); |
||
| 91 | } elseif (false === empty($company->telefono1)) { |
||
| 92 | static::$escpos->text(static::sanitize($company->telefono1) . "\n"); |
||
| 93 | } elseif (false === empty($company->telefono2)) { |
||
| 94 | static::$escpos->text(static::sanitize($company->telefono2) . "\n"); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | // imprimimos el título del documento |
||
| 99 | static::$escpos->text(static::sanitize($title) . "\n"); |
||
| 100 | |||
| 101 | static::setHeaderTPV($model, $printer); |
||
| 102 | |||
| 103 | // si es un documento de venta |
||
| 104 | // imprimimos la fecha y el cliente |
||
| 105 | if (in_array($model->modelClassName(), ['PresupuestoCliente', 'PedidoCliente', 'AlbaranCliente', 'FacturaCliente'])) { |
||
| 106 | static::$escpos->text(static::sanitize(static::$i18n->trans('date') . ': ' . $model->fecha . ' ' . $model->hora) . "\n"); |
||
| 107 | static::$escpos->text(static::sanitize(static::$i18n->trans('customer') . ': ' . $model->nombrecliente) . "\n\n"); |
||
| 108 | |||
| 109 | if ($model->modelClassName() == 'FacturaCliente') { |
||
| 110 | if (property_exists($model, 'numeroncf') && $model->numeroncf) { |
||
| 111 | static::$escpos->text(static::sanitize(static::$i18n->trans('ncf-number') . ': ' . $model->numeroncf)) . "\n"; |
||
| 112 | } |
||
| 113 | if (property_exists($model, 'tipocomprobante') && $model->tipocomprobante) { |
||
| 114 | static::$escpos->text(static::sanitize(static::$i18n->trans('tipo_comprobante') . ': ' . static::getTipoComprobanteRD($model->tipocomprobante))) . "\n"; |
||
| 115 | } |
||
| 116 | if (property_exists($model, 'ncffechavencimiento') && $model->ncffechavencimiento) { |
||
| 117 | static::$escpos->text(static::sanitize(static::$i18n->trans('due-date') . ': ' . $model->ncffechavencimiento)) . "\n"; |
||
| 118 | } |
||
| 119 | } |
||
| 120 | } |
||
| 121 | |||
| 122 | // añadimos la cabecera |
||
| 123 | if ($printer->head) { |
||
| 124 | static::$escpos->setJustification(Printer::JUSTIFY_CENTER); |
||
| 125 | static::$escpos->text(static::sanitize($printer->head) . "\n\n"); |
||
| 126 | static::$escpos->setJustification(); |
||
| 127 | } |
||
| 170 | } |
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