Issues (311)

src/XML/xenc11/Salt.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\xenc11;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
10
use SimpleSAML\XMLSchema\Exception\MissingElementException;
11
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
12
13
use function array_merge;
14
use function array_pop;
15
16
/**
17
 * Class representing <xenc11:Salt>.
18
 *
19
 * @package simplesamlphp/xml-security
20
 */
21
final class Salt extends AbstractXenc11Element
0 ignored issues
show
The type SimpleSAML\XMLSecurity\X...1\AbstractXenc11Element 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...
22
{
23
    /**
24
     * Salt constructor.
25
     *
26
     * @param \SimpleSAML\XMLSecurity\XML\xenc11\OtherSource|\SimpleSAML\XMLSecurity\XML\xenc11\Specified $content
27
     */
28
    public function __construct(
29
        protected OtherSource|Specified $content,
0 ignored issues
show
The type SimpleSAML\XMLSecurity\XML\xenc11\Specified 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...
30
    ) {
31
    }
32
33
34
    /**
35
     * Get the value of the $content property.
36
     *
37
     * @return \SimpleSAML\XMLSecurity\XML\xenc11\OtherSource|\SimpleSAML\XMLSecurity\XML\xenc11\Specified
38
     */
39
    public function getContent(): OtherSource|Specified
40
    {
41
        return $this->content;
42
    }
43
44
45
    /**
46
     * @inheritDoc
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, static::getLocalName(), InvalidDOMElementException::class);
54
        Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
55
56
        $otherSource = OtherSource::getChildrenOfClass($xml);
57
        $specified = Specified::getChildrenOfClass($xml);
58
59
        $content = array_merge($otherSource, $specified);
60
        Assert::minCount($content, 1, MissingElementException::class);
61
        Assert::maxCount($content, 1, TooManyElementsException::class);
62
63
        return new static(array_pop($content));
64
    }
65
66
67
    /**
68
     * @inheritDoc
69
     */
70
    public function toXML(?DOMElement $parent = null): DOMElement
71
    {
72
        $e = $this->instantiateParentElement($parent);
73
        $this->getContent()->toXML($e);
74
75
        return $e;
76
    }
77
}
78