| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace SimpleSAML\XMLSchema\XML\xs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use DOMElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SimpleSAML\XML\Assert\Assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SimpleSAML\XMLSchema\Exception\SchemaViolationException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SimpleSAML\XMLSchema\Type\Builtin\{BooleanValue, IDValue, NCNameValue}; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SimpleSAML\XMLSchema\Type\DerivationSetValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use function strval; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Abstract class representing the complexType-type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @package simplesamlphp/xml-common | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | abstract class AbstractComplexType extends AbstractAnnotated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     use ComplexTypeModelTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * ComplexType constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @param \SimpleSAML\XMLSchema\Type\Builtin\NCNameValue|null $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @param \SimpleSAML\XMLSchema\Type\Builtin\BooleanValue|null $mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @param \SimpleSAML\XMLSchema\Type\Builtin\BooleanValue|null $abstract | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param \SimpleSAML\XMLSchema\Type\DerivationSetValue|null $final | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @param \SimpleSAML\XMLSchema\Type\DerivationSetValue|null $block | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @param \SimpleSAML\XMLSchema\XML\xs\SimpleContent|\SimpleSAML\XMLSchema\XML\xs\ComplexContent|null $content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param \SimpleSAML\XMLSchema\XML\xs\TypeDefParticleInterface|null $particle | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @param ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      *   \SimpleSAML\XMLSchema\XML\xs\LocalAttribute| | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      *   \SimpleSAML\XMLSchema\XML\xs\ReferencedAttributeGroup | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * )[] $attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @param \SimpleSAML\XMLSchema\XML\xs\AnyAttribute|null $anyAttribute | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @param \SimpleSAML\XMLSchema\XML\xs\Annotation|null $annotation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @param \SimpleSAML\XMLSchema\Type\Builtin\IDValue|null $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         protected ?NCNameValue $name = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         protected ?BooleanValue $mixed = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         protected ?BooleanValue $abstract = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         protected ?DerivationSetValue $final = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         protected ?DerivationSetValue $block = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         SimpleContent|ComplexContent|null $content = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         ?TypeDefParticleInterface $particle = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         array $attributes = [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ?AnyAttribute $anyAttribute = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ?Annotation $annotation = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         ?IDValue $id = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         array $namespacedAttributes = [], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         if ($content !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             Assert::null($particle, SchemaViolationException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             Assert::isEmpty($attributes, SchemaViolationException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             Assert::null($anyAttribute, SchemaViolationException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             $this->setContent($content); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             Assert::null($content, SchemaViolationException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             $this->setParticle($particle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             $this->setAttributes($attributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             $this->setAnyAttribute($anyAttribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         parent::__construct($annotation, $id, $namespacedAttributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * Collect the value of the name-property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @return \SimpleSAML\XMLSchema\Type\Builtin\NCNameValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     public function getName(): ?NCNameValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         return $this->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * Collect the value of the mixed-property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @return \SimpleSAML\XMLSchema\Type\Builtin\BooleanValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     public function getMixed(): ?BooleanValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         return $this->mixed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * Collect the value of the abstract-property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * @return \SimpleSAML\XMLSchema\Type\Builtin\BooleanValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public function getAbstract(): ?BooleanValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return $this->abstract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * Collect the value of the final-property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @return \SimpleSAML\XMLSchema\Type\DerivationSetValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function getFinal(): ?DerivationSetValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return $this->final; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * Collect the value of the block-property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * @return \SimpleSAML\XMLSchema\Type\DerivationSetValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     public function getBlock(): ?DerivationSetValue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         return $this->block; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * Test if an object, at the state it's in, would produce an empty XML-element | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 134 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     public function isEmptyElement(): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |         return parent::isEmptyElement() && | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |             empty($this->getName()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |             empty($this->getMixed()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |             empty($this->getAbstract()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |             empty($this->getFinal()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |             empty($this->getBlock()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |             empty($this->getAttributes()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |             empty($this->getAnyAttribute()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |             empty($this->getParticle()) && | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |             empty($this->getContent()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * Add this ComplexType to an XML element. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      * @param \DOMElement|null $parent The element we should append this ComplexType to. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * @return \DOMElement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     public function toXML(?DOMElement $parent = null): DOMElement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         $e = parent::toXML($parent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         if ($this->getName() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             $e->setAttribute('name', strval($this->getName())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         if ($this->getMixed() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             $e->setAttribute('mixed', strval($this->getMixed())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         if ($this->getAbstract() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             $e->setAttribute('abstract', strval($this->getAbstract())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         if ($this->getFinal() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             $e->setAttribute('final', strval($this->getFinal())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         if ($this->getBlock() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             $e->setAttribute('block', strval($this->getBlock())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         if ($this->getContent() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             $this->getContent()->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             $this->getParticle()?->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             foreach ($this->getAttributes() as $attr) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |                 $attr->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             $this->getAnyAttribute()?->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         return $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 194 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 195 |  |  |  |