Passed
Push — master ( 88ea97...aa75e3 )
by Joe Nilson
02:36
created

WebserviceDgii::wdslSearch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 22
rs 9.9
1
<?php
2
/*
3
 * Copyright (C) 2022 Joe Nilson <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program 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
13
 * GNU Lesser General Public License for more details.
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Lib;
19
20
use FacturaScripts\Core\Base\DataBase;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase 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...
21
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase\DataBaseWhere 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...
22
use FacturaScripts\Dinamic\Model\Cliente;
0 ignored issues
show
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...
23
24
class WebserviceDgii
25
{
26
    /**
27
     * @var string
28
     */
29
    public $wsdlDGII = 'https://www.dgii.gov.do/wsMovilDGII/WSMovilDGII.asmx?WSDL';
30
31
    /**
32
     * @return void
33
     * @throws \SoapFault
34
     */
35
    public function wdslConnection(): object
36
    {
37
        return new \SoapClient($this->wsdlDGII, array('encoding' => 'UTF-8'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return new SoapClient($t...'encoding' => 'UTF-8')) returns the type SoapClient which is incompatible with the documented return type void.
Loading history...
38
    }
39
40
    /**
41
     * @param object $wsdlConn
42
     * @param integer $patronBusqueda
43
     * @param string $paramValue
44
     * @param integer $inicioFilas
45
     * @param integer $filaFilas
46
     * @return void
47
     * @throws \JsonException
48
     */
49
    public function wdslSearch(
50
        int $patronBusqueda = 0,
51
        string $paramValue = '',
52
        int $inicioFilas = 1,
53
        int $filaFilas = 1
54
    ): string
55
    {
56
        $opciones = [
57
            'patronBusqueda' => $patronBusqueda,
58
            'value' => $paramValue,
59
            'inicioFilas' => $inicioFilas,
60
            'filaFilas' => $filaFilas,
61
            'IMEI' => 0
62
        ];
63
64
        $wsdlConn = $this->wdslConnection();
65
66
        $result = $wsdlConn->__soapCall('GetContribuyentes', ['GetContribuyentes' => $opciones]);
67
        $list = array();
0 ignored issues
show
Unused Code introduced by
The assignment to $list is dead and can be removed.
Loading history...
68
        $getResult = explode("@@@", $result->GetContribuyentesResult);
69
70
        return $getResult[0];
0 ignored issues
show
Bug Best Practice introduced by
The expression return $getResult[0] returns the type string which is incompatible with the documented return type void.
Loading history...
71
    }
72
73
    /**
74
     * @param object $wsdlConn
75
     * @param string $paramValue
76
     * @return object
77
     */
78
    public function wdslSearchCount(object $wsdlConn, string $paramValue = ''): object
79
    {
80
        $opciones = [
81
            'value' => $paramValue,
82
            'IMEI' => 0
83
        ];
84
85
        $result = $wsdlConn->__soapCall('GetContribuyentesCount', ['GetContribuyentesCount' => $opciones]);
86
        return $result->GetContribuyentesCountResult;
87
    }
88
89
    /**
90
     * @param object $item
91
     * @return void
92
     */
93
    public function buscarCliente(&$item): void
94
    {
95
        $item->existe = false;
96
        $item->codcliente = '';
97
        $cli = new Cliente();
98
        $where = [
99
            new DataBaseWhere('cifnif' , $item->RGE_RUC)
100
        ];
101
        $cli->all($where);
102
        if ($cli[0] !== null) {
103
            $cliente = $cli[0];
104
            $item->existe = true;
105
            $item->codcliente = $cliente->codcliente;
106
        }
107
    }
108
}