| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class Storyblok |
||
| 11 | { |
||
| 12 | use HasChildClasses; |
||
| 13 | |||
| 14 | |||
| 15 | /** |
||
| 16 | * Reads the requested story from the API |
||
| 17 | * |
||
| 18 | * @param string $slug |
||
| 19 | * @param array|null $resolveRelations |
||
| 20 | * @param string|null $language |
||
| 21 | * @param string|null $fallbackLanguage |
||
| 22 | * @return Page |
||
| 23 | * @throws ApiException |
||
| 24 | */ |
||
| 25 | public function read(string $slug, array $resolveRelations = null, string $language = null, string $fallbackLanguage = null): Page |
||
| 26 | { |
||
| 27 | $storyblokRequest = new RequestStory(); |
||
| 28 | |||
| 29 | if ($resolveRelations) { |
||
| 30 | $storyblokRequest->resolveRelations($resolveRelations); |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($language) { |
||
| 34 | $storyblokRequest->language($language, $fallbackLanguage); |
||
| 35 | } |
||
| 36 | |||
| 37 | $response = $storyblokRequest->get($slug); |
||
| 38 | |||
| 39 | $class = $this->getChildClassName('Page', $response['content']['component']); |
||
| 40 | |||
| 41 | return new $class($response); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param $data |
||
| 46 | * @return mixed |
||
| 47 | */ |
||
| 48 | public function setData($data): mixed |
||
| 55 | } |
||
| 56 | } |