IterationCount::toXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
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\Type\PositiveIntegerValue;
11
12
use function strval;
13
14
/**
15
 * Class representing a xenc11:IterationCount element.
16
 *
17
 * @package simplesamlphp/xml-security
18
 */
19
final class IterationCount extends AbstractXenc11Element
0 ignored issues
show
Bug introduced by
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...
20
{
21
    /**
22
     * @param \SimpleSAML\XMLSchema\Type\PositiveIntegerValue $iterationCount
23
     */
24
    public function __construct(
25
        protected PositiveIntegerValue $iterationCount,
26
    ) {
27
    }
28
29
30
    /**
31
     * @return \SimpleSAML\XMLSchema\Type\PositiveIntegerValue
32
     */
33
    public function getIterationCount(): PositiveIntegerValue
34
    {
35
        return $this->iterationCount;
36
    }
37
38
39
    /**
40
     * Convert XML into a class instance
41
     *
42
     * @param \DOMElement $xml The XML element we should load
43
     *
44
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
45
     *   If the qualified name of the supplied element is wrong
46
     */
47
    public static function fromXML(DOMElement $xml): static
48
    {
49
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
50
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
51
52
        return new static(
53
            PositiveIntegerValue::fromString($xml->textContent),
54
        );
55
    }
56
57
58
    /**
59
     * Convert this element to XML.
60
     *
61
     * @param \DOMElement|null $parent The element we should append this element to.
62
     */
63
    public function toXML(?DOMElement $parent = null): DOMElement
64
    {
65
        $e = $this->instantiateParentElement($parent);
66
        $e->textContent = strval($this->getIterationCount());
67
68
        return $e;
69
    }
70
}
71