vendor/api-platform/core/src/OpenApi/Model/Operation.php line 170

  1. <?php
  2. /*
  3.  * This file is part of the API Platform project.
  4.  *
  5.  * (c) Kévin Dunglas <dunglas@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace ApiPlatform\OpenApi\Model;
  12. final class Operation
  13. {
  14.     use ExtensionTrait;
  15.     public function __construct(private ?string $operationId null, private ?array $tags null, private ?array $responses null, private ?string $summary null, private ?string $description null, private ?ExternalDocumentation $externalDocs null, private ?array $parameters null, private ?RequestBody $requestBody null, private ?\ArrayObject $callbacks null, private ?bool $deprecated null, private ?array $security null, private ?array $servers null, array $extensionProperties = [])
  16.     {
  17.         $this->extensionProperties $extensionProperties;
  18.     }
  19.     public function addResponse(Response $response$status 'default'): self
  20.     {
  21.         $this->responses[$status] = $response;
  22.         return $this;
  23.     }
  24.     public function getOperationId(): ?string
  25.     {
  26.         return $this->operationId;
  27.     }
  28.     public function getTags(): ?array
  29.     {
  30.         return $this->tags;
  31.     }
  32.     public function getResponses(): ?array
  33.     {
  34.         return $this->responses;
  35.     }
  36.     public function getSummary(): ?string
  37.     {
  38.         return $this->summary;
  39.     }
  40.     public function getDescription(): ?string
  41.     {
  42.         return $this->description;
  43.     }
  44.     public function getExternalDocs(): ?ExternalDocumentation
  45.     {
  46.         return $this->externalDocs;
  47.     }
  48.     public function getParameters(): ?array
  49.     {
  50.         return $this->parameters;
  51.     }
  52.     public function getRequestBody(): ?RequestBody
  53.     {
  54.         return $this->requestBody;
  55.     }
  56.     public function getCallbacks(): ?\ArrayObject
  57.     {
  58.         return $this->callbacks;
  59.     }
  60.     public function getDeprecated(): ?bool
  61.     {
  62.         return $this->deprecated;
  63.     }
  64.     public function getSecurity(): ?array
  65.     {
  66.         return $this->security;
  67.     }
  68.     public function getServers(): ?array
  69.     {
  70.         return $this->servers;
  71.     }
  72.     public function withOperationId(string $operationId): self
  73.     {
  74.         $clone = clone $this;
  75.         $clone->operationId $operationId;
  76.         return $clone;
  77.     }
  78.     public function withTags(array $tags): self
  79.     {
  80.         $clone = clone $this;
  81.         $clone->tags $tags;
  82.         return $clone;
  83.     }
  84.     public function withResponses(array $responses): self
  85.     {
  86.         $clone = clone $this;
  87.         $clone->responses $responses;
  88.         return $clone;
  89.     }
  90.     public function withResponse(int|string $statusResponse $response): self
  91.     {
  92.         $clone = clone $this;
  93.         if (!\is_array($clone->responses)) {
  94.             $clone->responses = [];
  95.         }
  96.         $clone->responses[(string) $status] = $response;
  97.         return $clone;
  98.     }
  99.     public function withSummary(string $summary): self
  100.     {
  101.         $clone = clone $this;
  102.         $clone->summary $summary;
  103.         return $clone;
  104.     }
  105.     public function withDescription(string $description): self
  106.     {
  107.         $clone = clone $this;
  108.         $clone->description $description;
  109.         return $clone;
  110.     }
  111.     public function withExternalDocs(ExternalDocumentation $externalDocs): self
  112.     {
  113.         $clone = clone $this;
  114.         $clone->externalDocs $externalDocs;
  115.         return $clone;
  116.     }
  117.     public function withParameters(array $parameters): self
  118.     {
  119.         $clone = clone $this;
  120.         $clone->parameters $parameters;
  121.         return $clone;
  122.     }
  123.     public function withParameter(Parameter $parameter): self
  124.     {
  125.         $clone = clone $this;
  126.         if (!\is_array($clone->parameters)) {
  127.             $clone->parameters = [];
  128.         }
  129.         $clone->parameters[] = $parameter;
  130.         return $clone;
  131.     }
  132.     public function withRequestBody(RequestBody $requestBody null): self
  133.     {
  134.         $clone = clone $this;
  135.         $clone->requestBody $requestBody;
  136.         return $clone;
  137.     }
  138.     public function withCallbacks(\ArrayObject $callbacks): self
  139.     {
  140.         $clone = clone $this;
  141.         $clone->callbacks $callbacks;
  142.         return $clone;
  143.     }
  144.     public function withDeprecated(bool $deprecated): self
  145.     {
  146.         $clone = clone $this;
  147.         $clone->deprecated $deprecated;
  148.         return $clone;
  149.     }
  150.     public function withSecurity(array $security null): self
  151.     {
  152.         $clone = clone $this;
  153.         $clone->security $security;
  154.         return $clone;
  155.     }
  156.     public function withServers(array $servers null): self
  157.     {
  158.         $clone = clone $this;
  159.         $clone->servers $servers;
  160.         return $clone;
  161.     }
  162. }