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