| @@ 9-48 (lines=40) @@ | ||
| 6 | ||
| 7 | use Aweapi\Openapi\Objects; |
|
| 8 | ||
| 9 | final class CallbackRequestBuilder implements Objects\CallbackRequestFactory |
|
| 10 | { |
|
| 11 | use Properties\OptionalExtensions; |
|
| 12 | ||
| 13 | private $items = []; |
|
| 14 | ||
| 15 | public function addItems(iterable $items): self |
|
| 16 | { |
|
| 17 | foreach ($items as $expression => $path) { |
|
| 18 | $this->setItem($expression, $path); |
|
| 19 | } |
|
| 20 | ||
| 21 | return $this; |
|
| 22 | } |
|
| 23 | ||
| 24 | public function createCallbackRequest(): Objects\CallbackRequest |
|
| 25 | { |
|
| 26 | return new Objects\CallbackRequest( |
|
| 27 | array_map( |
|
| 28 | static function (Objects\PathFactory $factory): Objects\Path { |
|
| 29 | return $factory->createPath(); |
|
| 30 | }, |
|
| 31 | $this->getItems() |
|
| 32 | ), |
|
| 33 | $this->getExtensions() |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function setItem(string $expression, Objects\PathFactory $path): self |
|
| 38 | { |
|
| 39 | $this->items[$expression] = $path; |
|
| 40 | ||
| 41 | return $this; |
|
| 42 | } |
|
| 43 | ||
| 44 | private function getItems(): array |
|
| 45 | { |
|
| 46 | return $this->items; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 9-48 (lines=40) @@ | ||
| 6 | ||
| 7 | use Aweapi\Openapi\Objects; |
|
| 8 | ||
| 9 | final class PathsBuilder implements Objects\PathsFactory |
|
| 10 | { |
|
| 11 | use Properties\OptionalExtensions; |
|
| 12 | ||
| 13 | private $paths = []; |
|
| 14 | ||
| 15 | public function addPaths(iterable $paths): self |
|
| 16 | { |
|
| 17 | foreach ($paths as $urlPath => $path) { |
|
| 18 | $this->setPath($urlPath, $path); |
|
| 19 | } |
|
| 20 | ||
| 21 | return $this; |
|
| 22 | } |
|
| 23 | ||
| 24 | public function createPaths(): Objects\Paths |
|
| 25 | { |
|
| 26 | return new Objects\Paths( |
|
| 27 | array_map( |
|
| 28 | static function (Objects\PathFactory $factory): Objects\Path { |
|
| 29 | return $factory->createPath(); |
|
| 30 | }, |
|
| 31 | $this->getPaths() |
|
| 32 | ), |
|
| 33 | $this->getExtensions() |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function setPath(string $urlPath, Objects\PathFactory $path): self |
|
| 38 | { |
|
| 39 | $this->paths[$urlPath] = $path; |
|
| 40 | ||
| 41 | return $this; |
|
| 42 | } |
|
| 43 | ||
| 44 | private function getPaths(): array |
|
| 45 | { |
|
| 46 | return $this->paths; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||