Conditions | 11 |
Paths | 1 |
Total Lines | 45 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
71 | public function saveBefore(): Closure |
||
72 | { |
||
73 | return function () { |
||
74 | if (null !== $this->codigorect && $this->idfactura === null) { |
||
75 | $this->cleanRefundData(); |
||
76 | } |
||
77 | |||
78 | $cliente = new Cliente(); |
||
79 | //$appSettins = new AppSettings; |
||
80 | $actualCliente = $cliente->get($this->codcliente); |
||
81 | $actualCliente->idempresa = Tools::settings('default', 'idempresa'); |
||
82 | $this->tipocomprobante = $this->tipocomprobante ?? $actualCliente->tipocomprobante; |
||
83 | $this->tipocomprobante = $_REQUEST['tipocomprobanter'] ?? $this->tipocomprobante; |
||
84 | if ($this->tipocomprobante !== '' && \in_array($this->numeroncf, ['', null], true)) { |
||
85 | $tipocomprobante = "02"; |
||
86 | if (($this->tipocomprobante !== null) === true) { |
||
87 | $tipocomprobante = $this->tipocomprobante; |
||
88 | } elseif (($this->tipocomprobante === null) === true) { |
||
89 | $tipocomprobante = $actualCliente->tipocomprobante; |
||
90 | } |
||
91 | |||
92 | if (true === in_array($this->numeroncf, ['',null])) { |
||
93 | $ncfrango = new NCFRango(); |
||
94 | $ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $tipocomprobante); |
||
95 | if (!$ncfRangoToUse) { |
||
96 | Tools::log()->error("no-ncf-range-for-$tipocomprobante"); |
||
97 | return false; |
||
98 | } |
||
99 | $ncf = $ncfRangoToUse->generateNCF(); |
||
100 | $this->numeroncf = $ncf; |
||
101 | $this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento; |
||
102 | $this->tipocomprobante = $ncfRangoToUse->tipocomprobante; |
||
103 | $ncfRangoToUse->correlativo++; |
||
104 | $ncfRangoToUse->save(); |
||
105 | } |
||
106 | |||
107 | //Verificamos si $this->tipoComprobante es una nota de crédito o debito |
||
108 | $arrayNCFTypes = ['03','04']; |
||
109 | if (in_array($this->tipocomprobante, $arrayNCFTypes) === true) { |
||
110 | $this->ncftipoanulacion = $_REQUEST['ncftipoanulacionr'] ?? $this->ncftipoanulacion; |
||
111 | $this->ncffechavencimiento = $_REQUEST['ncffechavencimientor'] ?? $this->ncffechavencimiento; |
||
112 | } |
||
113 | } |
||
114 | $this->ncffechavencimiento = ($this->ncffechavencimiento === '') ? null : $this->ncffechavencimiento; |
||
115 | return $this; |
||
116 | }; |
||
153 |
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