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; |
|
|
|
|
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
|
|
|
|
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.