|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the API Platform project. |
| 5 | + * |
| 6 | + * (c) Kévin Dunglas <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace ApiPlatform\OpenApi\Model; |
| 15 | + |
| 16 | +final class Header |
| 17 | +{ |
| 18 | + use ExtensionTrait; |
| 19 | + |
| 20 | + public function __construct(private readonly string $in = 'header', private string $description = '', private bool $required = false, private bool $deprecated = false, private bool $allowEmptyValue = false, private array $schema = [], private ?string $style = null, private bool $explode = false, private bool $allowReserved = false, private $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null) |
| 21 | + { |
| 22 | + if (null === $style) { |
| 23 | + $this->style = 'simple'; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + public function getIn(): string |
| 28 | + { |
| 29 | + return $this->in; |
| 30 | + } |
| 31 | + |
| 32 | + public function getDescription(): string |
| 33 | + { |
| 34 | + return $this->description; |
| 35 | + } |
| 36 | + |
| 37 | + public function getRequired(): bool |
| 38 | + { |
| 39 | + return $this->required; |
| 40 | + } |
| 41 | + |
| 42 | + public function getDeprecated(): bool |
| 43 | + { |
| 44 | + return $this->deprecated; |
| 45 | + } |
| 46 | + |
| 47 | + public function canAllowEmptyValue(): bool |
| 48 | + { |
| 49 | + return $this->allowEmptyValue; |
| 50 | + } |
| 51 | + |
| 52 | + public function getAllowEmptyValue(): bool |
| 53 | + { |
| 54 | + return $this->allowEmptyValue; |
| 55 | + } |
| 56 | + |
| 57 | + public function getSchema(): array |
| 58 | + { |
| 59 | + return $this->schema; |
| 60 | + } |
| 61 | + |
| 62 | + public function getStyle(): string |
| 63 | + { |
| 64 | + return $this->style; |
| 65 | + } |
| 66 | + |
| 67 | + public function canExplode(): bool |
| 68 | + { |
| 69 | + return $this->explode; |
| 70 | + } |
| 71 | + |
| 72 | + public function getExplode(): bool |
| 73 | + { |
| 74 | + return $this->explode; |
| 75 | + } |
| 76 | + |
| 77 | + public function canAllowReserved(): bool |
| 78 | + { |
| 79 | + return $this->allowReserved; |
| 80 | + } |
| 81 | + |
| 82 | + public function getAllowReserved(): bool |
| 83 | + { |
| 84 | + return $this->allowReserved; |
| 85 | + } |
| 86 | + |
| 87 | + public function getExample() |
| 88 | + { |
| 89 | + return $this->example; |
| 90 | + } |
| 91 | + |
| 92 | + public function getExamples(): ?\ArrayObject |
| 93 | + { |
| 94 | + return $this->examples; |
| 95 | + } |
| 96 | + |
| 97 | + public function getContent(): ?\ArrayObject |
| 98 | + { |
| 99 | + return $this->content; |
| 100 | + } |
| 101 | + |
| 102 | + public function withDescription(string $description): self |
| 103 | + { |
| 104 | + $clone = clone $this; |
| 105 | + $clone->description = $description; |
| 106 | + |
| 107 | + return $clone; |
| 108 | + } |
| 109 | + |
| 110 | + public function withRequired(bool $required): self |
| 111 | + { |
| 112 | + $clone = clone $this; |
| 113 | + $clone->required = $required; |
| 114 | + |
| 115 | + return $clone; |
| 116 | + } |
| 117 | + |
| 118 | + public function withDeprecated(bool $deprecated): self |
| 119 | + { |
| 120 | + $clone = clone $this; |
| 121 | + $clone->deprecated = $deprecated; |
| 122 | + |
| 123 | + return $clone; |
| 124 | + } |
| 125 | + |
| 126 | + public function withAllowEmptyValue(bool $allowEmptyValue): self |
| 127 | + { |
| 128 | + $clone = clone $this; |
| 129 | + $clone->allowEmptyValue = $allowEmptyValue; |
| 130 | + |
| 131 | + return $clone; |
| 132 | + } |
| 133 | + |
| 134 | + public function withSchema(array $schema): self |
| 135 | + { |
| 136 | + $clone = clone $this; |
| 137 | + $clone->schema = $schema; |
| 138 | + |
| 139 | + return $clone; |
| 140 | + } |
| 141 | + |
| 142 | + public function withStyle(string $style): self |
| 143 | + { |
| 144 | + $clone = clone $this; |
| 145 | + $clone->style = $style; |
| 146 | + |
| 147 | + return $clone; |
| 148 | + } |
| 149 | + |
| 150 | + public function withExplode(bool $explode): self |
| 151 | + { |
| 152 | + $clone = clone $this; |
| 153 | + $clone->explode = $explode; |
| 154 | + |
| 155 | + return $clone; |
| 156 | + } |
| 157 | + |
| 158 | + public function withAllowReserved(bool $allowReserved): self |
| 159 | + { |
| 160 | + $clone = clone $this; |
| 161 | + $clone->allowReserved = $allowReserved; |
| 162 | + |
| 163 | + return $clone; |
| 164 | + } |
| 165 | + |
| 166 | + public function withExample($example): self |
| 167 | + { |
| 168 | + $clone = clone $this; |
| 169 | + $clone->example = $example; |
| 170 | + |
| 171 | + return $clone; |
| 172 | + } |
| 173 | + |
| 174 | + public function withExamples(\ArrayObject $examples): self |
| 175 | + { |
| 176 | + $clone = clone $this; |
| 177 | + $clone->examples = $examples; |
| 178 | + |
| 179 | + return $clone; |
| 180 | + } |
| 181 | + |
| 182 | + public function withContent(\ArrayObject $content): self |
| 183 | + { |
| 184 | + $clone = clone $this; |
| 185 | + $clone->content = $content; |
| 186 | + |
| 187 | + return $clone; |
| 188 | + } |
| 189 | +} |
0 commit comments