Completed
Push — master ( e7d66f...77a53e )
by Roberto
04:50 queued 02:26
created

SoapFake   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 13.03%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 53
ccs 3
cts 23
cp 0.1303
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B send() 0 40 2
1
<?php
2
3
namespace NFePHP\Common\Soap;
4
5
/**
6
 * Soap fake class used for development only
7
 *
8
 * @category  NFePHP
9
 * @package   NFePHP\Common\Soap\SoapFake
10
 * @copyright NFePHP Copyright (c) 2017
11
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
12
 * @license   https://opensource.org/licenses/MIT MIT
13
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
14
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
15
 * @link      http://github.com/nfephp-org/sped-common for the canonical source repository
16
 */
17
use NFePHP\Common\Soap\SoapBase;
18
use NFePHP\Common\Soap\SoapInterface;
19
use NFePHP\Common\Exception\SoapException;
20
use NFePHP\Common\Certificate;
21
use Psr\Log\LoggerInterface;
22
23
class SoapFake extends SoapBase implements SoapInterface
24
{
25
    /**
26
     * Constructor
27
     * @param Certificate $certificate
28
     * @param LoggerInterface $logger
29
     */
30 2
    public function __construct(Certificate $certificate = null, LoggerInterface $logger = null)
31
    {
32 2
        parent::__construct($certificate, $logger);
33 2
    }
34
    
35
    public function send(
36
        $url,
37
        $operation = '',
38
        $action = '',
39
        $soapver = SOAP_1_2,
40
        $parameters = [],
41
        $namespaces = [],
42
        $request = '',
43
        $soapheader = null
44
    ) {
45
        $response = '';
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
46
        $envelope = $this->makeEnvelopeSoap(
47
            $request,
48
            $operation,
49
            $namespaces,
50
            $soapver,
51
            $soapheader
52
        );
53
        $msgSize = strlen($envelope);
54
        $parameters = [
55
            "Content-Type: application/soap+xml;charset=utf-8;",
56
            "Content-length: $msgSize"
57
        ];
58
        if (!empty($action)) {
59
            $parameters[0] .= "action=$action";
60
        }
61
        $requestHead = implode("\n", $parameters);
62
        $requestBody = $envelope;
63
        
64
        return json_encode([
65
            'url' => $url,
66
            'operation' => $operation,
67
            'action' => $action,
68
            'soapver' => $soapver,
69
            'parameters' => $parameters,
70
            'header' => $requestHead,
71
            'namespaces' => $namespaces,
72
            'body' => $requestBody
73
        ], JSON_PRETTY_PRINT);
74
    }
75
}
76