| Total Complexity | 7 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ChainedResources implements ApiResourcesInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string[] |
||
| 13 | */ |
||
| 14 | private $static = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var ApiResourcesInterface[] |
||
| 18 | */ |
||
| 19 | private $chainedResources = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param (string|ApiResourcesInterface)[] $resources |
||
| 23 | */ |
||
| 24 | public function __construct(array $resources) |
||
| 25 | { |
||
| 26 | foreach ($resources as $resource) |
||
| 27 | { |
||
| 28 | if (gettype($resource) === 'string' && class_exists($resource)) { |
||
| 29 | $this->static[] = $resource; |
||
| 30 | continue; |
||
| 31 | } |
||
| 32 | if ($resource instanceof ApiResourcesInterface) { |
||
| 33 | $this->chainedResources[] = $resource; |
||
| 34 | continue; |
||
| 35 | } |
||
| 36 | throw new BadConfigurationException('I expect to get a list of classes or ApiResourcesInterface instances.'); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritDoc} |
||
| 42 | */ |
||
| 43 | public function getApiResources(): array |
||
| 50 | } |
||
| 51 | } |
||
| 52 |