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