1 | <?php namespace Neomerx\JsonApi\Http\Query; |
||
26 | class BaseQueryParser implements BaseQueryParserInterface |
||
27 | { |
||
28 | /** Message */ |
||
29 | public const MSG_ERR_INVALID_PARAMETER = 'Invalid Parameter.'; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $parameters; |
||
35 | |||
36 | /** |
||
37 | * @var string[]|null |
||
38 | */ |
||
39 | private $messages; |
||
40 | |||
41 | /** |
||
42 | * @param array $parameters |
||
43 | * @param string[]|null $messages |
||
44 | */ |
||
45 | 12 | public function __construct(array $parameters = [], array $messages = null) |
|
50 | |||
51 | /** |
||
52 | * @param array $parameters |
||
53 | * |
||
54 | * @return self |
||
55 | */ |
||
56 | 12 | public function setParameters(array $parameters): self |
|
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | */ |
||
66 | 9 | public function getIncludes(): iterable |
|
81 | |||
82 | /** |
||
83 | * @inheritdoc |
||
84 | */ |
||
85 | 3 | public function getFields(): iterable |
|
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | 1 | public function getSorts(): iterable |
|
126 | |||
127 | /** |
||
128 | * @param string $paramName |
||
129 | * @param string|mixed $shouldBeString |
||
130 | * @param string $separator |
||
131 | * |
||
132 | * @return iterable |
||
133 | */ |
||
134 | 10 | protected function splitString(string $paramName, $shouldBeString, string $separator): iterable |
|
144 | |||
145 | /** |
||
146 | * @param string $paramName |
||
147 | * @param string|mixed $shouldBeString |
||
148 | * @param string $separator |
||
149 | * |
||
150 | * @return iterable |
||
151 | */ |
||
152 | 10 | protected function splitStringAndCheckNoEmpties(string $paramName, $shouldBeString, string $separator): iterable |
|
163 | |||
164 | /** |
||
165 | * @param string $paramName |
||
166 | * @param string|mixed $shouldBeString |
||
167 | * |
||
168 | * @return iterable |
||
169 | */ |
||
170 | 10 | protected function splitCommaSeparatedStringAndCheckNoEmpties(string $paramName, $shouldBeString): iterable |
|
174 | |||
175 | /** |
||
176 | * @return array |
||
177 | */ |
||
178 | 12 | protected function getParameters(): array |
|
182 | |||
183 | /** |
||
184 | * @param string $parameterName |
||
185 | * |
||
186 | * @return Error |
||
187 | */ |
||
188 | 6 | protected function createParameterError(string $parameterName): Error |
|
192 | |||
193 | /** |
||
194 | * @param string $name |
||
195 | * @param string $title |
||
196 | * |
||
197 | * @return Error |
||
198 | */ |
||
199 | 6 | protected function createQueryError(string $name, string $title): Error |
|
207 | |||
208 | /** |
||
209 | * @param string $message |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | 6 | protected function getMessage(string $message): string |
|
219 | } |
||
220 |