Passed
Push — master ( 8a423f...9c95d4 )
by Joe Nilson
01:52
created

FacturaCliente::saveInsert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 14
rs 9.8666
c 1
b 0
f 1
1
<?php
2
/**
3
 * Copyright (C) 2020 joenilson.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 3 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA 02110-1301  USA
19
 */
20
21
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Model;
22
23
use FacturaScripts\Plugins\fsRepublicaDominicana\Model\NCFRango;
24
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, FacturaScripts\Plugins\f...Extension\Model\Cliente. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
Bug introduced by
The type FacturaScripts\Dinamic\Model\Cliente was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use FacturaScripts\Core\App\AppSettings;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\App\AppSettings was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
/**
28
 * Description of FacturaCliente
29
 *
30
 * @author joenilson
31
 */
32
class FacturaCliente
33
{
34
    /**
35
     *
36
     * @var date
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Plugins\f...na\Extension\Model\date was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
37
     */
38
    public $ncffechavencimiento;
39
    /**
40
     * @var string
41
     */
42
    public $tipocomprobante;
43
    /**
44
     *
45
     * @var string
46
     */
47
    public $ncftipopago;
48
    /**
49
     *
50
     * @var string
51
     */
52
    public $ncftipoanulacion;
53
    
54
    public function saveInsert()
55
    {
56
        return function () {
57
            $ncfrango = new NCFRango();
58
            $cliente = new Cliente();
59
            $actualCliente = $cliente->get($this->codcliente);
0 ignored issues
show
Bug Best Practice introduced by
The property codcliente does not exist on FacturaScripts\Plugins\f...on\Model\FacturaCliente. Did you maybe forget to declare it?
Loading history...
60
            $actualCliente->idempresa = AppSettings::get('default', 'idempresa');
61
            $ncfRangoToUse = $ncfrango->getByTipoComprobante($actualCliente->idempresa, $actualCliente->codsubtipodoc);
62
            $ncf = $ncfRangoToUse->generateNCF();
63
            $this->numero2 = $ncf;
0 ignored issues
show
Bug Best Practice introduced by
The property numero2 does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
64
            $this->ncffechavencimiento = $ncfRangoToUse->fechavencimiento;
65
            $this->tipocomprobante = $ncfRangoToUse->tipocomprobante;
66
            $ncfRangoToUse->correlativo++;
67
            $ncfRangoToUse->save();
68
        };
69
    }
70
}
71