AbstractSimpleType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 6
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\XML;
6
7
use DOMElement;
8
use SimpleSAML\XMLSchema\Type\IDValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\IDValue 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...
9
use SimpleSAML\XMLSchema\Type\NCNameValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\NCNameValue 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...
10
use SimpleSAML\XMLSchema\Type\Schema\SimpleDerivationSetValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Typ...impleDerivationSetValue 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
use SimpleSAML\XMLSchema\XML\Interface\SimpleDerivationInterface;
12
use SimpleSAML\XMLSchema\XML\Trait\SimpleDerivationTrait;
13
14
use function strval;
15
16
/**
17
 * Abstract class representing the abstract simpleType.
18
 *
19
 * @package simplesamlphp/xml-common
20
 */
21
abstract class AbstractSimpleType extends AbstractAnnotated
22
{
23
    use SimpleDerivationTrait;
24
25
26
    /**
27
     * SimpleType constructor
28
     *
29
     * @param \SimpleSAML\XMLSchema\XML\Interface\SimpleDerivationInterface $derivation
30
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue $name
31
     * @param \SimpleSAML\XMLSchema\Type\Schema\SimpleDerivationSetValue $final
32
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
33
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
34
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
35
     */
36
    public function __construct(
37
        SimpleDerivationInterface $derivation,
38
        protected ?NCNameValue $name = null,
39
        protected ?SimpleDerivationSetValue $final = null,
40
        ?Annotation $annotation = null,
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\XML\Annotation 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...
41
        ?IDValue $id = null,
42
        array $namespacedAttributes = [],
43
    ) {
44
        parent::__construct($annotation, $id, $namespacedAttributes);
45
46
        $this->setDerivation($derivation);
47
    }
48
49
50
    /**
51
     * Collect the value of the final-property
52
     *
53
     * @return \SimpleSAML\XMLSchema\Type\Schema\SimpleDerivationSetValue|null
54
     */
55
    public function getFinal(): ?SimpleDerivationSetValue
56
    {
57
        return $this->final;
58
    }
59
60
61
    /**
62
     * Collect the value of the name-property
63
     *
64
     * @return \SimpleSAML\XMLSchema\Type\NCNameValue|null
65
     */
66
    public function getName(): ?NCNameValue
67
    {
68
        return $this->name;
69
    }
70
71
72
    /**
73
     * Test if an object, at the state it's in, would produce an empty XML-element
74
     *
75
     * @return bool
76
     */
77
    public function isEmptyElement(): bool
78
    {
79
        return false;
80
    }
81
82
83
    /**
84
     * Add this SimpleType to an XML element.
85
     *
86
     * @param \DOMElement|null $parent The element we should append this SimpleType to.
87
     * @return \DOMElement
88
     */
89
    public function toXML(?DOMElement $parent = null): DOMElement
90
    {
91
        $e = parent::toXML($parent);
92
93
        if ($this->getFinal() !== null) {
94
            $e->setAttribute('final', strval($this->getFinal()));
95
        }
96
97
        if ($this->getName() !== null) {
98
            $e->setAttribute('name', strval($this->getName()));
99
        }
100
101
        $this->getDerivation()->toXML($e);
102
103
        return $e;
104
    }
105
}
106