1 | <?php |
||
18 | class FractalTransformFactory implements TransformFactory |
||
19 | { |
||
20 | /** |
||
21 | * A manager for executing transforms. |
||
22 | * |
||
23 | * @var \League\Fractal\Manager |
||
24 | */ |
||
25 | protected $manager; |
||
26 | |||
27 | /** |
||
28 | * Construct the factory class. |
||
29 | * |
||
30 | * @param \League\Fractal\Manager $manager |
||
31 | */ |
||
32 | 1 | public function __construct(Manager $manager) |
|
36 | |||
37 | /** |
||
38 | * Transform the given resource, and serialize the data with the given serializer. |
||
39 | * |
||
40 | * @param \League\Fractal\Resource\ResourceInterface $resource |
||
41 | * @param \League\Fractal\Serializer\SerializerAbstract $serializer |
||
42 | * @param array $options |
||
43 | * @return array |
||
44 | */ |
||
45 | 1 | public function make(ResourceInterface $resource, SerializerAbstract $serializer, array $options = []): array |
|
56 | |||
57 | /** |
||
58 | * Parse the transformation options. |
||
59 | * |
||
60 | * @param array $options |
||
61 | * @param \League\Fractal\Resource\ResourceInterface $resource |
||
62 | * @return array |
||
63 | */ |
||
64 | 1 | protected function parseOptions(array $options, ResourceInterface $resource): array |
|
82 | |||
83 | /** |
||
84 | * Parse the fieldsets for Fractal. |
||
85 | * |
||
86 | * @param array $fieldsets |
||
87 | * @param string $resourceKey |
||
88 | * @param array $includes |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function parseFieldsets(array $fieldsets, string $resourceKey, array $includes): array |
||
108 | |||
109 | /** |
||
110 | * Parse the given fieldset and append any related resource keys. |
||
111 | * |
||
112 | * @param string $key |
||
113 | * @param array $fields |
||
114 | * @param array $includes |
||
115 | * @return string |
||
116 | */ |
||
117 | protected function parseFieldset(string $key, array $fields, array $includes): string |
||
125 | |||
126 | /** |
||
127 | * Resolve included segments that are a direct child to the given resource key. |
||
128 | * |
||
129 | * @param string $key |
||
130 | * @param string $include |
||
131 | * @return array |
||
132 | */ |
||
133 | protected function resolveChildIncludes($key, string $include): array |
||
143 | } |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.