Passed
Pull Request — master (#18)
by Tim
08:00 queued 05:44
created

KeyName::fromXML()   A

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\ds;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\XMLStringElementTrait;
11
12
13
/**
14
 * Class representing a ds:KeyName element.
15
 *
16
 * @package simplesamlphp/xml-security
17
 */
18
final class KeyName extends AbstractDsElement
19
{
20
    use XMLStringElementTrait;
21
22
23
    /**
24
     * Validate the content of the element.
25
     *
26
     * @param string $content  The value to go in the XML textContent
27
     * @throws \Exception on failure
28
     * @return void
29
     */
30
    private function validateContent(string $content): void
0 ignored issues
show
Unused Code introduced by
The parameter $content is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
    private function validateContent(/** @scrutinizer ignore-unused */ string $content): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The method validateContent() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
31
    {
32
        /**
33
         * Perform no validation by default.
34
         * Override this method on the implementing class to perform content validation.
35
         */
36
    }
37
38
39
    /**
40
     * Convert XML into a KeyName
41
     *
42
     * @param \DOMElement $xml The XML element we should load
43
     * @return self
44
     *
45
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
46
     *   If the qualified name of the supplied element is wrong
47
     */
48
    public static function fromXML(DOMElement $xml): object
49
    {
50
        Assert::same($xml->localName, 'KeyName', InvalidDOMElementException::class);
51
        Assert::same($xml->namespaceURI, KeyName::NS, InvalidDOMElementException::class);
52
53
        return new self($xml->textContent);
54
    }
55
}
56