1 | <?php |
||
9 | class ResourceFactory |
||
10 | { |
||
11 | /** |
||
12 | * @param Explorer $explorer |
||
13 | * @param array $data |
||
14 | * @return HalResource|ResourceCollection |
||
15 | * @throws InvalidResourceException |
||
16 | */ |
||
17 | 5 | public static function create(Explorer $explorer, $data) |
|
27 | |||
28 | /** |
||
29 | * @param Explorer $explorer |
||
30 | * @param array $data |
||
31 | * @return ResourceCollection |
||
32 | */ |
||
33 | private static function createCollection(Explorer $explorer, array $data) |
||
34 | { |
||
35 | $collection = new ResourceCollection($explorer); |
||
36 | foreach ($data as $itemData) { |
||
37 | $collection->addResource(self::create($explorer, $itemData)); |
||
38 | } |
||
39 | return $collection; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param Explorer $explorer |
||
44 | * @param array $data |
||
45 | * @return HalResource |
||
46 | */ |
||
47 | 5 | private static function createResource(Explorer $explorer, array $data) |
|
61 | |||
62 | /** |
||
63 | * @param Explorer $explorer |
||
64 | * @param EmbeddableInterface $resource |
||
65 | * @param array $embedded |
||
66 | */ |
||
67 | 5 | private static function parseEmbedded(Explorer $explorer, EmbeddableInterface $resource, array $embedded) |
|
73 | |||
74 | /** |
||
75 | * @param Explorer $explorer |
||
76 | * @param HalResource $resource |
||
77 | * @param array $links |
||
78 | */ |
||
79 | 5 | private static function parseLinks(Explorer $explorer, HalResource $resource, array $links) |
|
85 | } |
||
86 |