1 | <?php |
||
17 | final class JsonApiExceptionThrower implements QueryExceptionThrowerInterface |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * @param string $key |
||
22 | * |
||
23 | * @throws \Exception |
||
24 | */ |
||
25 | 16 | public function invalidValueForKey(string $key): void |
|
26 | { |
||
27 | 16 | $this->throwException(sprintf('Invalid value provided for key `%s`.', $key)); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param string $message |
||
32 | * |
||
33 | * @throws \Exception |
||
34 | */ |
||
35 | 16 | private function throwException(string $message): void |
|
36 | { |
||
37 | 16 | $uuid = Uuid::getFactory()->uuid4()->toString(); |
|
38 | |||
39 | 16 | $error = new Error( |
|
40 | 16 | $uuid, |
|
41 | 16 | null, |
|
42 | 16 | 'error', |
|
43 | 16 | '400', |
|
44 | 16 | $message |
|
45 | ); |
||
46 | |||
47 | 16 | throw new JsonApiException($error); |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param string $operator |
||
52 | * |
||
53 | * @throws \Exception |
||
54 | */ |
||
55 | public function operatorIsNotDefined(string $operator): void |
||
59 | |||
60 | /** |
||
61 | * @param string $operator |
||
62 | * |
||
63 | * @throws \Exception |
||
64 | */ |
||
65 | public function invalidValueForOperator(string $operator): void |
||
69 | |||
70 | /** |
||
71 | * @param string $field |
||
72 | * @param string $expectedType |
||
73 | * |
||
74 | * @throws \Throwable |
||
75 | */ |
||
76 | public function invalidValueForField(string $field, string $expectedType): void |
||
82 | } |
||
83 |