| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace WsdlToPhp\PackageGenerator\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use WsdlToPhp\PackageGenerator\Generator\Utils; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use WsdlToPhp\PackageGenerator\Container\Model\StructValue as StructValueContainer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use WsdlToPhp\PackageGenerator\Container\Model\StructAttribute as StructAttributeContainer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use WsdlToPhp\PackageGenerator\Generator\Generator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Class Struct stands for an available struct described in the WSDL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class Struct extends AbstractModel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     const DOC_SUB_PACKAGE_STRUCTS = 'Structs'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     const DOC_SUB_PACKAGE_ENUMERATIONS = 'Enumerations'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     const DOC_SUB_PACKAGE_ARRAYS = 'Arrays'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * Attributes of the struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @var StructAttributeContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     private $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * Is the struct a restriction with defined values  ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     private $isRestriction = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * If the struct is a restriction with values, then store values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @var StructValueContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     private $values; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * Define if the urrent struct is a concrete struct or just a virtual struct to store meta informations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     private $isStruct = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * Main constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @see AbstractModel::__construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @uses Struct::setIsStruct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @param Generator $generator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @param string $name the original name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @param bool $isStruct defines if it's a real sruct or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @param bool $isRestriction defines if it's an enumeration or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 472 |  |     public function __construct(Generator $generator, $name, $isStruct = true, $isRestriction = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 472 |  |         parent::__construct($generator, $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 354 |  |         $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 472 |  |             ->setIsStruct($isStruct) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 472 |  |             ->setIsRestriction($isRestriction) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 472 |  |             ->setAttributes(new StructAttributeContainer($generator)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 472 |  |             ->setValues(new StructValueContainer($generator)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 472 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * Returns the contextual part of the class name for the package | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @see AbstractModel::getContextualPart() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @uses Struct::getIsRestriction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 212 |  |     public function getContextualPart() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 212 |  |         $part = $this->getGenerator()->getOptionStructsFolder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 212 |  |         if ($this->getIsRestriction()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 76 |  |             $part = $this->getGenerator()->getOptionEnumsFolder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 203 |  |         } elseif ($this->isArray()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 44 |  |             $part = $this->getGenerator()->getOptionArraysFolder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 33 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 212 |  |         return $part; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * Returns the sub package name which the model belongs to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * Must be overridden by sub classes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @see AbstractModel::getDocSubPackages() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @uses Struct::getIsRestriction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 88 | 116 |  |     public function getDocSubPackages() | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 90 | 116 |  |         $package = self::DOC_SUB_PACKAGE_STRUCTS; | 
            
                                                                        
                            
            
                                    
            
            
                | 91 | 116 |  |         if ($this->getIsRestriction()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 92 | 52 |  |             $package = self::DOC_SUB_PACKAGE_ENUMERATIONS; | 
            
                                                                        
                            
            
                                    
            
            
                | 93 | 108 |  |         } elseif ($this->isArray()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 94 | 28 |  |             $package = self::DOC_SUB_PACKAGE_ARRAYS; | 
            
                                                                        
                            
            
                                    
            
            
                | 95 | 21 |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |         return array( | 
            
                                                                        
                            
            
                                    
            
            
                | 97 | 116 |  |             $package, | 
            
                                                                        
                            
            
                                    
            
            
                | 98 | 87 |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * Returns true if the current struct is a collection of values (like an array) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @uses AbstractModel::getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @uses Struct::countOwnAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 228 |  |     public function isArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 228 |  |         return ($this->countOwnAttributes() === 1 && stripos($this->getName(), 'array') !== false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * Returns the attributes of the struct and potentially from the parent class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @uses AbstractModel::getInheritance() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @uses Struct::getIsStruct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @uses Struct::getAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @param bool $includeInheritanceAttributes include the attributes of parent class, default parent attributes are not included. If true, then the array is an associative array containing and index "attribute" for the StructAttribute object and an index "model" for the Struct object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @param bool $requiredFirst places the required attributes first, then the not required in order to have the _contrust method with the required attribute at first | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @return StructAttributeContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 240 |  |     public function getAttributes($includeInheritanceAttributes = false, $requiredFirst = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 240 |  |         if ($includeInheritanceAttributes === false && $requiredFirst === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 240 |  |             $attributes = $this->attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 180 |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 80 |  |             $attributes = $this->getAllAttributes($includeInheritanceAttributes, $requiredFirst); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 240 |  |         return $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @param bool $includeInheritanceAttributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * @param bool $requiredFirst | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * @return StructAttributeContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 80 |  |     protected function getAllAttributes($includeInheritanceAttributes, $requiredFirst) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 80 |  |         $allAttributes = new StructAttributeContainer($this->getGenerator()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 80 |  |         if ($includeInheritanceAttributes === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 4 |  |             $this->addInheritanceAttributes($allAttributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 80 |  |         foreach ($this->attributes as $attribute) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 80 |  |             $allAttributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 60 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 80 |  |         if ($requiredFirst === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 80 |  |             $attributes = $this->putRequiredFirst($allAttributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 60 |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             $attributes = $allAttributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 80 |  |         return $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * @param StructAttributeContainer $attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 4 |  |     protected function addInheritanceAttributes(StructAttributeContainer $attributes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 4 |  |         if ($this->getInheritance() != '' && ($model = $this->getInheritanceStruct()) instanceof Struct) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             while ($model->getIsStruct()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 foreach ($model->getAttributes() as $attribute) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                     $attributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 $model = $this->getGenerator()->getStruct($model->getInheritance()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 4 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * @param StructAttributeContainer $allAttributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * @return StructAttributeContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 80 |  |     protected function putRequiredFirst(StructAttributeContainer $allAttributes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 | 80 |  |         $attributes = new StructAttributeContainer($this->getGenerator()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 80 |  |         $requiredAttributes = new StructAttributeContainer($this->getGenerator()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 80 |  |         $notRequiredAttributes = new StructAttributeContainer($this->getGenerator()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 80 |  |         foreach ($allAttributes as $attribute) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 | 80 |  |             if ($attribute->isRequired()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 24 |  |                 $requiredAttributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 18 |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 74 |  |                 $notRequiredAttributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 60 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 80 |  |         foreach ($requiredAttributes as $attribute) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 24 |  |             $attributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 60 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 80 |  |         foreach ($notRequiredAttributes as $attribute) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 | 72 |  |             $attributes->add($attribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 60 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 80 |  |         unset($requiredAttributes, $notRequiredAttributes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 80 |  |         return $attributes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * Returns the number of own attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @uses Struct::getAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 | 228 |  |     public function countOwnAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 228 |  |         return $this->getAttributes(false, false)->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * Sets the attributes of the struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * @param StructAttributeContainer $structAttributeContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 472 |  |     public function setAttributes(StructAttributeContainer $structAttributeContainer) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 472 |  |         $this->attributes = $structAttributeContainer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 472 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * Adds attribute based on its original name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @throws \InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * @param string $attributeName the attribute name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * @param string $attributeType the attribute type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 420 |  |     public function addAttribute($attributeName, $attributeType) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 | 420 |  |         if (empty($attributeName) || empty($attributeType)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 8 |  |             throw new \InvalidArgumentException(sprintf('Attribute name "%s" and/or attribute type "%s" is invalid for Struct "%s"', $attributeName, $attributeType, $this->getName()), __LINE__); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 | 412 |  |         if ($this->attributes->getStructAttributeByName($attributeName) === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 408 |  |             $structAttribute = new StructAttribute($this->getGenerator(), $attributeName, $attributeType, $this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 408 |  |             $this->attributes->add($structAttribute); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 | 306 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 412 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |      * Returns the attribute by its name, otherwise null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |      * @uses Struct::getAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * @param string $attributeName the original attribute name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * @return StructAttribute|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 | 280 |  |     public function getAttribute($attributeName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 280 |  |         return $this->attributes->getStructAttributeByName($attributeName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * Returns the isRestriction value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 244 |  |     public function getIsRestriction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 244 |  |         return $this->isRestriction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |      * Sets the isRestriction value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      * @param bool $isRestriction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 | 472 |  |     public function setIsRestriction($isRestriction = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 | 472 |  |         $this->isRestriction = $isRestriction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 | 472 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |      * Returns the isStruct value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 | 172 |  |     public function getIsStruct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 | 172 |  |         return $this->isStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      * Sets the isStruct value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * @param bool $isStruct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 | 472 |  |     public function setIsStruct($isStruct = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 | 472 |  |         $this->isStruct = $isStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 | 472 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |      * Returns the values for an enumeration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      * @return StructValueContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 | 264 |  |     public function getValues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 | 264 |  |         return $this->values; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      * Sets the values for an enumeration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |      * @param StructValueContainer $structValueContainer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 | 472 |  |     private function setValues(StructValueContainer $structValueContainer) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 | 472 |  |         $this->values = $structValueContainer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 | 472 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |      * Adds value to values array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * @uses Struct::getValue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * @uses Struct::getValues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      * @param mixed $value the original value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      * @return Struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 | 268 |  |     public function addValue($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 | 268 |  |         if ($this->getValue($value) === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 264 |  |             $this->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 | 264 |  |             $this->setIsRestriction(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 | 264 |  |             $this->setIsStruct(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 | 198 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 | 268 |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * Gets the value object for the given value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * @uses Struct::getValues() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @uses AbstractModel::getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      * @param string $value Value name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      * @return StructValue|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 | 268 |  |     public function getValue($value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 | 268 |  |         return $this->values->getStructValueByName($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |      * Allows to define from which class the curent model extends | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * @param bool $short | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 | 108 |  |     public function getExtends($short = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 | 108 |  |         $extends = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 | 108 |  |         if ($this->isArray()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 | 28 |  |             $extends = $this->getGenerator()->getOptionStructArrayClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 | 103 |  |         } elseif (!$this->getIsRestriction()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 | 60 |  |             $extends = $this->getGenerator()->getOptionStructClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 | 45 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 | 108 |  |         return $short ? Utils::removeNamespace($extends) : $extends; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |      * @return Struct|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 | 136 |  |     public function getInheritanceStruct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 136 |  |         return $this->getGenerator()->getStruct($this->getInheritance()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |      * @see \WsdlToPhp\PackageGenerator\Model\AbstractModel::getMeta() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |      * @return string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 | 136 |  |     public function getMeta() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 | 136 |  |         $inheritanceStruct = $this->getInheritanceStruct(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 | 136 |  |         return array_merge_recursive(parent::getMeta(), ($inheritanceStruct && !$inheritanceStruct->getIsStruct()) ? $inheritanceStruct->getMeta() : array()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 347 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 348 |  |  |  |