| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Aweapi\Openapi\Objects; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Aweapi\Openapi\Extensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Aweapi\Openapi\ValueObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class Parameter extends ValueObject implements ParameterAggregate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     use Properties\OptionalDeprecationStatus; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     use Properties\OptionalDescription; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     use Properties\OptionalExamples; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     use Properties\OptionalMediaTypeContent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     use Properties\OptionalExtensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private $allowEmptyValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $allowReserved; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $explode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private $in; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $required; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     private $schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     private $style; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 14 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         string $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         string $in, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         SchemaAggregate $schema = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         MediaTypes $content = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         string $description = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         bool $required = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         bool $deprecated = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         bool $allowEmptyValue = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         string $style = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         bool $explode = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         bool $allowReserved = false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         Examples $examples = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         Extensions $extensions = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 14 |  |         $this->name = $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 14 |  |         $this->in = $in; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 14 |  |         $this->schema = $schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 14 |  |         $this->content = $content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 14 |  |         $this->description = $description; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 14 |  |         $this->required = $required; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 14 |  |         $this->deprecated = $deprecated; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 14 |  |         $this->allowEmptyValue = $allowEmptyValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 14 |  |         $this->style = $style; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         // TODO: The defaults is based on other fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 14 |  |         $this->explode = (bool) $explode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 14 |  |         $this->allowReserved = $allowReserved; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 14 |  |         $this->examples = $examples; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 14 |  |         $this->extensions = $extensions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 12 |  |     public function getIn(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 12 |  |         return $this->in; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 12 |  |     public function getName(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 12 |  |         return $this->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 5 |  |     public function getSchema(): SchemaAggregate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 5 |  |         return $this->schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 2 |  |     public function getStyle(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 2 |  |         return $this->style; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 12 |  |     public function hasSchema(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 12 |  |         return isset($this->schema); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 12 |  |     public function hasStyle(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 12 |  |         return isset($this->style); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 12 |  |     public function isAllowEmptyValue(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 12 |  |         return $this->allowEmptyValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 100 | 12 |  |     public function isAllowReserved(): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 102 | 12 |  |         return $this->allowReserved; | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 12 |  |     public function isExplode(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 12 |  |         return $this->explode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 2 |  |     public function isRequired(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 2 |  |         return $this->required === true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 12 |  |     public function jsonSerialize(): ?array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 12 |  |         return $this->extendedProperties(parent::jsonSerialize()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 12 |  |     protected function normalizeOptionalProperties(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 12 |  |             'schema' => $this->hasSchema() ? $this->getSchema()->jsonSerialize() : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 12 |  |             'content' => $this->getNormalizedContent(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 12 |  |             'description' => $this->getNormalizedDescription(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 12 |  |             'required' => $this->isRequiredSet() ? $this->isRequired() : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 12 |  |             'deprecated' => $this->isDeprecated() ?: null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 12 |  |             'allowEmptyValue' => $this->isAllowEmptyValue() ?: null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 12 |  |             'style' => $this->hasStyle() ? $this->getStyle() : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 12 |  |             'explode' => $this->isExplode() ?: null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 12 |  |             'allowReserved' => $this->isAllowReserved() ?: null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 12 |  |             'examples' => $this->hasExamples() ? $this->getExamples()->jsonSerialize() : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 12 |  |     protected function normalizeRequiredProperties(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 12 |  |             'name' => $this->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 12 |  |             'in' => $this->getIn(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 12 |  |     private function isRequiredSet(): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 12 |  |         return isset($this->required); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 149 |  |  |  |