SoapDebug::getDumper()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
ccs 0
cts 5
cp 0
crap 2
rs 9.7333
1
<?php
2
namespace Eduardokum\CorreiosPhp\Soap;
3
4
use Eduardokum\CorreiosPhp\Contracts\Soap\Soap as SoapContract;
5
use Symfony\Component\VarDumper\Cloner\VarCloner;
6
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
7
8
class SoapDebug extends Soap implements SoapContract
9
{
10
    public function send($url, array $action = [], $request = '', $namespaces = [], $auth = [])
11
    {
12
        $result = new \stdClass();
13
        $result->args = func_get_args();
14
        $result->request = $request = $this->envelop($request, $namespaces);
15
        $result->headers = array_filter([
16
            'Content-Type: text/xml;charset=utf-8',
17
            array_key_exists('curl', $action) && !empty(trim($action['curl'])) ? sprintf('SOAPAction: "%s"', $action['curl']) : null,
18
            'Accept: text/xml',
19
            'Cache-Control: no-cache',
20
            'Pragma: no-cache',
21
            sprintf('Content-length: %s', strlen($request)),
22
        ]);
23
24
        $this->getDumper()->dump((new VarCloner())->cloneVar($result));
25
        die;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
26
    }
27
28
    /**
29
     * @return HtmlDumper
30
     */
31
    private function getDumper()
32
    {
33
        $htmlDumper = new HtmlDumper();
34
        $htmlDumper->setStyles([
35
            'default' => 'background-color:#fff; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all',
36
            'num' => 'font-weight:bold; color:#000000',
37
            'const' => 'font-weight:bold',
38
            'str' => 'font-weight:bold; color:#888888',
39
            'note' => 'color:#555555; font-weight: bold;',
40
            'ref' => 'color:#b72904',
41
            'public' => 'color:#111111; font-weight: bold;',
42
            'protected' => 'color:#111111; font-weight: bold;',
43
            'private' => 'color:#111111; font-weight: bold;',
44
            'meta' => 'color:#b72904',
45
            'key' => 'color:#000000',
46
            'index' => 'color:#000000',
47
            'ellipsis' => 'color:#111111',
48
        ]);
49
        return $htmlDumper;
50
    }
51
}
52