|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the php-epp2 library. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Gunter Grodotzki <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE file |
|
9
|
|
|
* that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace AfriCC\EPP\Frame; |
|
13
|
|
|
|
|
14
|
|
|
use AfriCC\EPP\AbstractFrame; |
|
15
|
|
|
use AfriCC\EPP\DOM\DOMTools; |
|
16
|
|
|
use AfriCC\EPP\Frame\Response\Result; |
|
17
|
|
|
use DOMNodeList; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @see http://tools.ietf.org/html/rfc5730#section-2.6 |
|
21
|
|
|
*/ |
|
22
|
|
|
class Response extends AbstractFrame |
|
23
|
|
|
{ |
|
24
|
|
|
public function results() |
|
25
|
|
|
{ |
|
26
|
|
|
$results = []; |
|
27
|
|
|
$nodes = $this->get('//epp:epp/epp:response/epp:result'); |
|
28
|
|
|
foreach ($nodes as $node) { |
|
|
|
|
|
|
29
|
|
|
$results[] = new Result($node); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
return $results; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function success() |
|
36
|
|
|
{ |
|
37
|
|
|
$code = $this->code(); |
|
38
|
|
|
if ($code >= 1000 && $code < 2000) { |
|
39
|
|
|
return true; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return false; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function code() |
|
46
|
|
|
{ |
|
47
|
|
|
return (int) $this->get('//epp:epp/epp:response/epp:result/@code'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function message() |
|
51
|
|
|
{ |
|
52
|
|
|
return (string) $this->get('//epp:epp/epp:response/epp:result/epp:msg/text()'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function clientTransactionId() |
|
56
|
|
|
{ |
|
57
|
|
|
$value = $this->get('//epp:epp/epp:response/epp:trID/epp:clTRID/text()'); |
|
58
|
|
|
if ($value === false) { |
|
59
|
|
|
return; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return (string) $value; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function serverTransactionId() |
|
66
|
|
|
{ |
|
67
|
|
|
$value = $this->get('//epp:epp/epp:response/epp:trID/epp:svTRID/text()'); |
|
68
|
|
|
if ($value === false) { |
|
69
|
|
|
return; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return (string) $value; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function data() |
|
76
|
|
|
{ |
|
77
|
|
|
$nodes = $this->get('//epp:epp/epp:response/epp:resData'); |
|
78
|
|
|
if ($nodes === false || !($nodes instanceof DOMNodeList) || $nodes->length === 0 || !$nodes->item(0)->hasChildNodes()) { |
|
79
|
|
|
$data = []; |
|
80
|
|
|
} else { |
|
81
|
|
|
$data = DOMTools::nodeToArray($nodes->item(0)); |
|
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
// check for extension data |
|
85
|
|
|
$nodes = $this->get('//epp:epp/epp:response/epp:extension'); |
|
86
|
|
|
if ($nodes !== false && $nodes instanceof DOMNodeList && $nodes->length > 0 && $nodes->item(0)->hasChildNodes()) { |
|
87
|
|
|
$data = array_merge_recursive($data, DOMTools::nodeToArray($nodes->item(0))); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return $data; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.