@@ -96,7 +96,7 @@ public function getElements($path, \DOMElement $contextNode = null)
96
96
* @param string $path
97
97
* @return \DOMElement|null
98
98
*/
99
- public function getElement ($ path , \DOMElement $ contextNode )
99
+ public function getElement ($ path , \DOMElement $ contextNode = null )
100
100
{
101
101
$ elements = $ this ->getElements ($ path , $ contextNode );
102
102
if ($ elements ->length > 0 ) {
@@ -113,16 +113,17 @@ public function getElement($path, \DOMElement $contextNode)
113
113
* @param string $path
114
114
* @return string|null
115
115
*/
116
- public function getAttribute ($ attribute , \DOMElement $ contextNode , $ path = null )
116
+ public function getAttribute ($ attribute , \DOMElement $ contextNode = null , $ path = null )
117
117
{
118
- if (is_null ($ path )) {
119
- $ return = $ contextNode ->getAttribute ($ attribute );
120
- } else {
118
+ $ return = null ;
119
+ if ($ path !== null ) {
121
120
$ elements = $ this ->getElements ($ path , $ contextNode );
122
121
if ($ elements ->length > 0 ) {
123
122
$ return = $ elements ->item (0 )->getAttribute ($ attribute );
124
- } else {
125
- $ return = null ;
123
+ }
124
+ } else {
125
+ if ($ contextNode !== null ) {
126
+ $ return = $ contextNode ->getAttribute ($ attribute );
126
127
}
127
128
}
128
129
@@ -135,7 +136,7 @@ public function getAttribute($attribute, \DOMElement $contextNode, $path = null)
135
136
* @param string $path
136
137
* @return string|null
137
138
*/
138
- public function getValue ($ path , \DOMElement $ contextNode )
139
+ public function getValue ($ path , \DOMElement $ contextNode = null )
139
140
{
140
141
$ elements = $ this ->getElements ($ path , $ contextNode );
141
142
if ($ elements ->length > 0 ) {
@@ -151,7 +152,7 @@ public function getValue($path, \DOMElement $contextNode)
151
152
* @param string $path
152
153
* @return integer
153
154
*/
154
- public function countElements ($ path , \DOMElement $ contextNode )
155
+ public function countElements ($ path , \DOMElement $ contextNode = null )
155
156
{
156
157
$ elements = $ this ->getElements ($ path , $ contextNode );
157
158
@@ -164,7 +165,7 @@ public function countElements($path, \DOMElement $contextNode)
164
165
* @param string $path
165
166
* @return boolean
166
167
*/
167
- public function elementExists ($ path , \DOMElement $ contextNode )
168
+ public function elementExists ($ path , \DOMElement $ contextNode = null )
168
169
{
169
170
return $ this ->getElements ($ path , $ contextNode )->length > 0 ;
170
171
}
0 commit comments