Passed
Pull Request — master (#64)
by Tim
02:46 queued 42s
created

AbstractECValidationDataType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHashAlgorithm() 0 3 1
A __construct() 0 5 1
A getSeed() 0 3 1
A toXML() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\dsig11;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
11
/**
12
 * Abstract class representing a dsig11:ECValidationDataType
13
 *
14
 * @package simplesaml/xml-security
15
 */
16
abstract class AbstractECValidationDataType extends AbstractDsig11Element
17
{
18
    /**
19
     * Initialize a ECValidationDataType element.
20
     *
21
     * @param \SimpleSAML\XMLSecurity\XML\dsig11\Seed $seed
22
     * @param string $hashAlgorithm
23
     */
24
    public function __construct(
25
        protected Seed $seed,
26
        protected string $hashAlgorithm,
27
    ) {
28
        Assert::validURI($hashAlgorithm, SchemaViolationException::class);
29
    }
30
31
32
    /**
33
     * Collect the value of the seed-property
34
     *
35
     * @return \SimpleSAML\XMLSecurity\XML\dsig11\Seed
36
     */
37
    public function getSeed(): Seed
38
    {
39
        return $this->seed;
40
    }
41
42
43
    /**
44
     * Collect the value of the hashAlgorithm-property
45
     *
46
     * @return string
47
     */
48
    public function getHashAlgorithm(): string
49
    {
50
        return $this->hashAlgorithm;
51
    }
52
53
54
    /**
55
     * Convert this ECValidationDataType element to XML.
56
     *
57
     * @param \DOMElement|null $parent The element we should append this ECValidationDataType element to.
58
     * @return \DOMElement
59
     */
60
    public function toXML(?DOMElement $parent = null): DOMElement
61
    {
62
        $e = $this->instantiateParentElement($parent);
63
        $e->setAttribute('hashAlgorithm', $this->getHashAlgorithm());
64
65
        $this->getSeed()->toXML($e);
66
67
        return $e;
68
    }
69
}
70