1 | <?php |
||
16 | abstract class ResourceAbstract implements ResourceInterface |
||
17 | { |
||
18 | /** |
||
19 | * Any item to process. |
||
20 | * |
||
21 | * @var mixed |
||
22 | */ |
||
23 | protected $data; |
||
24 | |||
25 | /** |
||
26 | * Array of meta data. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $meta = []; |
||
31 | |||
32 | /** |
||
33 | * The resource key. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $resourceKey; |
||
38 | |||
39 | /** |
||
40 | * A callable to process the data attached to this resource. |
||
41 | * |
||
42 | * @var callable|TransformerAbstract|null |
||
43 | */ |
||
44 | protected $transformer; |
||
45 | |||
46 | /** |
||
47 | * Create a new resource instance. |
||
48 | * |
||
49 | * @param mixed $data |
||
50 | * @param callable|TransformerAbstract|null $transformer |
||
51 | * @param string $resourceKey |
||
52 | */ |
||
53 | 76 | public function __construct($data = null, $transformer = null, $resourceKey = null) |
|
59 | |||
60 | /** |
||
61 | * Get the data. |
||
62 | * |
||
63 | * @return mixed |
||
64 | */ |
||
65 | 63 | public function getData() |
|
69 | |||
70 | /** |
||
71 | * Set the data. |
||
72 | * |
||
73 | * @param mixed $data |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | 1 | public function setData($data) |
|
83 | |||
84 | /** |
||
85 | * Get the meta data. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 59 | public function getMeta() |
|
93 | |||
94 | /** |
||
95 | * Get the meta data. |
||
96 | * |
||
97 | * @param string $metaKey |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | 1 | public function getMetaValue($metaKey) |
|
105 | |||
106 | /** |
||
107 | * Get the resource key. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 63 | public function getResourceKey() |
|
115 | |||
116 | /** |
||
117 | * Get the transformer. |
||
118 | * |
||
119 | * @return callable|TransformerAbstract |
||
120 | */ |
||
121 | 65 | public function getTransformer() |
|
125 | |||
126 | /** |
||
127 | * Set the transformer. |
||
128 | * |
||
129 | * @param callable|TransformerAbstract $transformer |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | 1 | public function setTransformer($transformer) |
|
139 | |||
140 | /** |
||
141 | * Set the meta data. |
||
142 | * |
||
143 | * @param array $meta |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | 1 | public function setMeta(array $meta) |
|
153 | |||
154 | /** |
||
155 | * Set the meta data. |
||
156 | * |
||
157 | * @param string $metaKey |
||
158 | * @param mixed $metaValue |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 16 | public function setMetaValue($metaKey, $metaValue) |
|
168 | |||
169 | /** |
||
170 | * Set the resource key. |
||
171 | * |
||
172 | * @param string $resourceKey |
||
173 | * |
||
174 | * @return $this |
||
175 | */ |
||
176 | 3 | public function setResourceKey($resourceKey) |
|
182 | } |
||
183 |