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