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