SoapFake   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 21 1
1
<?php
2
3
namespace NFePHP\eFinanc\Common\Soap;
4
5
/**
6
 * Soap fake class used for development only
7
 *
8
 * @category  API
9
 * @package   NFePHP\eFinanc
10
 * @copyright NFePHP Copyright (c) 2018
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-efinanceira for the canonical source repository
16
 */
17
use NFePHP\eFinanc\Common\Soap\SoapBase;
18
use NFePHP\eFinanc\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
    public function __construct(Certificate $certificate = null, LoggerInterface $logger = null)
31
    {
32
        parent::__construct($certificate, $logger);
33
    }
34
    
35
    public function send(
36
        $operation,
37
        $url,
38
        $action,
39
        $envelope,
40
        $parameters
41
    ) {
42
        $requestHead = implode("\n", $parameters);
43
        $requestBody = $envelope;
44
        
45
        return json_encode([
46
            'url' => $url,
47
            'operation' => $operation,
48
            'action' => $action,
49
            'soapver' => '1.1',
50
            'parameters' => $parameters,
51
            'header' => $requestHead,
52
            'namespaces' => [],
53
            'body' => $requestBody
54
        ], JSON_PRETTY_PRINT);
55
    }
56
}
57