|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\EFDReinf\Common; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class FakePretty shows event and fake comunication data for analises and debugging |
|
7
|
|
|
* |
|
8
|
|
|
* @category API |
|
9
|
|
|
* @package NFePHP\EFDReinf |
|
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-efdreinf for the canonical source repository |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
class FakePretty |
|
19
|
|
|
{ |
|
20
|
|
|
public static function prettyPrint($response, $save = '') |
|
21
|
|
|
{ |
|
22
|
|
|
if (empty($response)) { |
|
23
|
|
|
$html = "Sem resposta"; |
|
24
|
|
|
return $html; |
|
25
|
|
|
} |
|
26
|
|
|
$std = json_decode($response); |
|
27
|
|
|
if (!empty($save)) { |
|
28
|
|
|
file_put_contents( |
|
29
|
|
|
"/var/www/sped/sped-efdreinf/tests/fixtures/xml/$save.xml", |
|
30
|
|
|
$std->body |
|
31
|
|
|
); |
|
32
|
|
|
} |
|
33
|
|
|
$doc = new \DOMDocument('1.0', 'UTF-8'); |
|
34
|
|
|
$doc->preserveWhiteSpace = false; |
|
35
|
|
|
$doc->formatOutput = true; |
|
36
|
|
|
$doc->loadXML($std->body); |
|
37
|
|
|
|
|
38
|
|
|
$html = "<pre>"; |
|
39
|
|
|
$html .= '<h2>url</h2>'; |
|
40
|
|
|
$html .= $std->url; |
|
41
|
|
|
$html .= "<br>"; |
|
42
|
|
|
$html .= '<h2>operation</h2>'; |
|
43
|
|
|
$html .= "<br>"; |
|
44
|
|
|
$html .= $std->operation; |
|
45
|
|
|
$html .= "<br>"; |
|
46
|
|
|
$html .= '<h2>action</h2>'; |
|
47
|
|
|
$html .= $std->action; |
|
48
|
|
|
$html .= "<br>"; |
|
49
|
|
|
$html .= '<h2>soapver</h2>'; |
|
50
|
|
|
$html .= $std->soapver; |
|
51
|
|
|
$html .= "<br>"; |
|
52
|
|
|
$html .= '<h2>parameters</h2>'; |
|
53
|
|
|
foreach ($std->parameters as $key => $param) { |
|
54
|
|
|
$html .= "[$key] => $param <br>"; |
|
55
|
|
|
} |
|
56
|
|
|
$html .= "<br>"; |
|
57
|
|
|
$html .= '<h2>header</h2>'; |
|
58
|
|
|
$html .= $std->header; |
|
59
|
|
|
$html .= "<br>"; |
|
60
|
|
|
$html .= '<h2>namespaces</h2>'; |
|
61
|
|
|
$an = json_decode(json_encode($std->namespaces), true); |
|
62
|
|
|
foreach ($an as $key => $nam) { |
|
63
|
|
|
$html .= "[$key] => $nam <br>"; |
|
64
|
|
|
} |
|
65
|
|
|
$html .= "<br>"; |
|
66
|
|
|
$html .= '<h2>body</h2>'; |
|
67
|
|
|
$html .= str_replace( |
|
68
|
|
|
['<', '>'], |
|
69
|
|
|
['<','>'], |
|
70
|
|
|
str_replace( |
|
71
|
|
|
'<?xml version="1.0"?>', |
|
72
|
|
|
'<?xml version="1.0" encoding="UTF-8"?>', |
|
73
|
|
|
$doc->saveXML() |
|
74
|
|
|
) |
|
75
|
|
|
); |
|
76
|
|
|
$html .= "</pre>"; |
|
77
|
|
|
return $html; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|