XPathMethods   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 3 1
A query() 0 3 1
A firstOf() 0 3 1
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\SweetDOM
5
* @copyright Copyright (c) The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\SweetDOM\NodeTraits;
9
10
use DOMNode;
11
use DOMNodeList;
12
13
trait XPathMethods
14
{
15
	/**
16
	* Evaluate and return the result of a given XPath expression using this element as context node
17
	*/
18
	public function evaluate(string $expression): mixed
19
	{
20
		return $this->ownerDocument->evaluate($expression, $this);
21
	}
22
23
	/**
24
	* Evaluate and return the first element of a given XPath query using this element as context node
25
	*/
26
	public function firstOf(string $expression): ?DOMNode
27
	{
28
		return $this->ownerDocument->firstOf($expression, $this);
29
	}
30
31
	/**
32
	* Evaluate and return the result of a given XPath query using this element as context node
33
	*/
34
	public function query(string $expression): DOMNodeList
35
	{
36
		return $this->ownerDocument->query($expression, $this);
37
	}
38
}