Conditions | 5 |
Paths | 7 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
22 | public function find($expression, $contextnode = NULL) |
||
23 | { |
||
24 | if ($expression instanceof \DOMNode) |
||
25 | return $expression; |
||
26 | |||
27 | @ $items = $contextnode ? $this->query($expression, $contextnode) : $this->query($expression); |
||
|
|||
28 | |||
29 | if ( ! $items) |
||
30 | throw new Exception_Xpath('Error in expression: ":expression"', array(':expression' => $expression)); |
||
31 | |||
32 | if ($items->length == 0) |
||
33 | throw new Exception_Xpath('No element for selector ":expression"', array(':expression' => $expression)); |
||
34 | |||
35 | return $items->item(0); |
||
36 | |||
37 | } |
||
38 | } |
||
39 |
If you suppress an error, we recommend checking for the error condition explicitly: