1 | <?php declare (strict_types=1); |
||
5 | abstract class AbstractParams |
||
6 | { |
||
7 | // locations |
||
8 | const QUERY = 'query'; |
||
9 | const HEADER = 'header'; |
||
10 | const URL = 'url'; |
||
11 | const JSON = 'json'; |
||
12 | const RAW = 'raw'; |
||
13 | |||
14 | // types |
||
15 | const STRING_TYPE = "string"; |
||
16 | const BOOL_TYPE = "boolean"; |
||
17 | const BOOLEAN_TYPE = self::BOOL_TYPE; |
||
18 | const OBJECT_TYPE = "object"; |
||
19 | const ARRAY_TYPE = "array"; |
||
20 | const NULL_TYPE = "NULL"; |
||
21 | const INT_TYPE = 'integer'; |
||
22 | const INTEGER_TYPE = self::INT_TYPE; |
||
23 | |||
24 | public static function isSupportedLocation(string $val): bool |
||
28 | |||
29 | public function limit(): array |
||
30 | { |
||
31 | return [ |
||
32 | 'type' => self::INT_TYPE, |
||
33 | 'location' => 'query', |
||
34 | 'description' => <<<DESC |
||
35 | This will limit the total amount of elements returned in a list up to the number specified. For example, specifying a |
||
36 | limit of 10 will return 10 elements, regardless of the actual count. |
||
37 | DESC |
||
38 | ]; |
||
39 | } |
||
40 | |||
41 | public function marker(): array |
||
42 | { |
||
43 | return [ |
||
44 | 'type' => 'string', |
||
45 | 'location' => 'query', |
||
46 | 'description' => <<<DESC |
||
47 | Specifying a marker will begin the list from the value specified. Elements will have a particular attribute that |
||
48 | identifies them, such as a name or ID. The marker value will search for an element whose identifying attribute matches |
||
49 | the marker value, and begin the list from there. |
||
50 | DESC |
||
51 | ]; |
||
52 | } |
||
53 | |||
54 | public function id(string $type): array |
||
55 | { |
||
56 | return [ |
||
57 | 'description' => sprintf("The unique ID, or identifier, for the %s", $type), |
||
58 | 'type' => self::STRING_TYPE, |
||
59 | 'location' => self::JSON, |
||
60 | ]; |
||
61 | } |
||
62 | |||
63 | public function idPath(): array |
||
71 | |||
72 | public function name(string $resource): array |
||
73 | { |
||
74 | return [ |
||
75 | 'description' => sprintf("The name of the %s", $resource), |
||
76 | 'type' => self::STRING_TYPE, |
||
77 | 'location' => self::JSON, |
||
78 | ]; |
||
79 | } |
||
80 | |||
81 | |||
82 | public function sortDir(): array |
||
91 | |||
92 | public function sortKey(): array |
||
100 | } |
||
101 |