1 | <?php |
||
30 | abstract class Factory |
||
31 | { |
||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | public $tpInsc; |
||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | public $nrInsc; |
||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | public $nmRazao; |
||
44 | /** |
||
45 | * @var DateTime |
||
46 | */ |
||
47 | public $date; |
||
48 | /** |
||
49 | * @var int |
||
50 | */ |
||
51 | public $tpAmb = 3; |
||
52 | /** |
||
53 | * @var int |
||
54 | */ |
||
55 | public $procEmi = 1; |
||
56 | /** |
||
57 | * @var string |
||
58 | */ |
||
59 | public $verProc = ''; |
||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | public $layout = ''; |
||
64 | /** |
||
65 | * @var string |
||
66 | */ |
||
67 | public $layoutStr = ''; |
||
68 | /** |
||
69 | * @var string |
||
70 | */ |
||
71 | public $schema = ''; |
||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | public $jsonschema = ''; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $xmlns = "http://www.reinf.esocial.gov.br/schemas/"; |
||
81 | /** |
||
82 | * @var Dom |
||
83 | */ |
||
84 | protected $dom; |
||
85 | /** |
||
86 | * @var stdClass |
||
87 | */ |
||
88 | protected $std; |
||
89 | /** |
||
90 | * @var string |
||
91 | */ |
||
92 | protected $xml; |
||
93 | /** |
||
94 | * @var \DOMElement |
||
95 | */ |
||
96 | protected $reinf; |
||
97 | /** |
||
98 | * @var \DOMElement |
||
99 | */ |
||
100 | protected $node; |
||
101 | /** |
||
102 | * @var string |
||
103 | */ |
||
104 | public $evtid = ''; |
||
105 | /** |
||
106 | * @var string |
||
107 | */ |
||
108 | protected $evtTag; |
||
109 | /** |
||
110 | * @var string |
||
111 | */ |
||
112 | protected $evtName = ''; |
||
113 | /** |
||
114 | * @var string |
||
115 | */ |
||
116 | protected $evtAlias = ''; |
||
117 | /** |
||
118 | * @var Certificate|null |
||
119 | */ |
||
120 | protected $certificate; |
||
121 | |||
122 | /** |
||
123 | * Constructor |
||
124 | * @param string $config |
||
125 | * @param stdClass $std |
||
126 | * @param Certificate $certificate |
||
127 | * @param string $date |
||
128 | */ |
||
129 | public function __construct( |
||
175 | |||
176 | /** |
||
177 | * Stringfy layout number |
||
178 | * @param string $layout |
||
179 | * @return string |
||
180 | */ |
||
181 | protected function strLayoutVer($layout) |
||
190 | |||
191 | /** |
||
192 | * Change properties names of stdClass to lower case |
||
193 | * @param stdClass $data |
||
194 | * @return stdClass |
||
195 | */ |
||
196 | protected static function propertiesToLower(stdClass $data) |
||
209 | |||
210 | /** |
||
211 | * Validation json data from json Schema |
||
212 | * @param stdClass $data |
||
213 | * @return boolean |
||
214 | * @throws \RuntimeException |
||
215 | */ |
||
216 | protected function validInputData($data) |
||
232 | |||
233 | /** |
||
234 | * Initialize DOM |
||
235 | */ |
||
236 | protected function init() |
||
275 | |||
276 | /** |
||
277 | * Returns alias of event |
||
278 | * @return string |
||
279 | */ |
||
280 | public function alias() |
||
284 | |||
285 | /** |
||
286 | * Returns the Certificate::class |
||
287 | * @return Certificate|null |
||
288 | */ |
||
289 | public function getCertificate() |
||
293 | |||
294 | /** |
||
295 | * Insert Certificate::class |
||
296 | * @param Certificate $certificate |
||
297 | */ |
||
298 | public function setCertificate(Certificate $certificate) |
||
302 | |||
303 | /** |
||
304 | * Recover calculate ID |
||
305 | * @return string |
||
306 | */ |
||
307 | public function getId() |
||
311 | |||
312 | /** |
||
313 | * Return xml of event |
||
314 | * @return string |
||
315 | */ |
||
316 | public function toXML() |
||
323 | |||
324 | abstract protected function toNode(); |
||
325 | |||
326 | /** |
||
327 | * Remove XML declaration from XML string |
||
328 | * @param string $xml |
||
329 | * @return string |
||
330 | */ |
||
331 | protected function clearXml($xml) |
||
339 | |||
340 | /** |
||
341 | * Convert xml of event to array |
||
342 | * @return array |
||
343 | */ |
||
344 | public function toArray() |
||
348 | |||
349 | /** |
||
350 | * Convert xml to json string |
||
351 | * @return string |
||
352 | */ |
||
353 | public function toJson() |
||
370 | |||
371 | /** |
||
372 | * Convert xml to stdClass |
||
373 | * @return stdClass |
||
374 | */ |
||
375 | public function toStd() |
||
379 | |||
380 | /** |
||
381 | * Adjust missing properties form original data according schema |
||
382 | * @param \stdClass $data |
||
383 | * @return \stdClass |
||
384 | */ |
||
385 | //public function standardizeProperties(stdClass $data) |
||
386 | //{ |
||
387 | // if (!is_file($this->jsonschema)) { |
||
388 | // return $data; |
||
389 | // } |
||
390 | // $jsonSchemaObj = json_decode(file_get_contents($this->jsonschema)); |
||
391 | // $sc = new ParamsStandardize($jsonSchemaObj); |
||
392 | // return $sc->stdData($data); |
||
393 | //} |
||
394 | |||
395 | /** |
||
396 | * Sign and validate XML with XSD, can throw Exception |
||
397 | * @param string $tagsigned tag to be base of signature |
||
398 | */ |
||
399 | protected function sign($tagsigned = '') |
||
417 | } |
||
418 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.