Issues (311)

src/XML/ds/XPath.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\ds;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
10
use SimpleSAML\XMLSchema\Type\StringValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\StringValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
use function strval;
13
14
/**
15
 * Class implementing the XPath element.
16
 *
17
 * @package simplesamlphp/xml-security
18
 */
19
final class XPath extends AbstractDsElement
0 ignored issues
show
The type SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
{
21
    /**
22
     * Construct an XPath element.
23
     *
24
     * @param \SimpleSAML\XMLSchema\Type\StringValue $expression The XPath expression itself.
25
     */
26
    final public function __construct(
27
        protected StringValue $expression,
28
    ) {
29
    }
30
31
32
    /**
33
     * Get the actual XPath expression.
34
     *
35
     * @return \SimpleSAML\XMLSchema\Type\StringValue
36
     */
37
    public function getExpression(): StringValue
38
    {
39
        return $this->expression;
40
    }
41
42
43
    /**
44
     * Convert XML into a class instance
45
     *
46
     * @param \DOMElement $xml
47
     *
48
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
49
     *   If the qualified name of the supplied element is wrong
50
     */
51
    public static function fromXML(DOMElement $xml): static
52
    {
53
        Assert::same($xml->localName, 'XPath', InvalidDOMElementException::class);
54
        Assert::same($xml->namespaceURI, self::NS, InvalidDOMElementException::class);
55
56
        return new static(StringValue::fromString($xml->textContent));
57
    }
58
59
60
    /**
61
     * @param \DOMElement|null $parent
62
     */
63
    public function toXML(?DOMElement $parent = null): DOMElement
64
    {
65
        $e = $this->instantiateParentElement($parent);
66
        $e->textContent = strval($this->getExpression());
67
68
        return $e;
69
    }
70
}
71