1 | <?php declare (strict_types=1); |
||
16 | class Operation |
||
17 | { |
||
18 | /** @var string The HTTP method */ |
||
19 | private $method; |
||
20 | |||
21 | /** @var string The URL path */ |
||
22 | private $path; |
||
23 | |||
24 | /** @var string The top-level JSON key */ |
||
25 | private $jsonKey; |
||
26 | |||
27 | /** @var []Parameter The parameters of this operation */ |
||
28 | private $params; |
||
29 | |||
30 | /** |
||
31 | * @param array $definition The data definition (in array form) that will populate this |
||
32 | * operation. Usually this is retrieved from an {@see ApiInterface} |
||
33 | * object method. |
||
34 | */ |
||
35 | public function __construct(array $definition) |
||
46 | |||
47 | 211 | /** |
|
48 | 211 | * @return string |
|
49 | */ |
||
50 | public function getPath(): string |
||
54 | |||
55 | 203 | /** |
|
56 | * @return string |
||
57 | */ |
||
58 | public function getMethod(): string |
||
62 | |||
63 | 203 | /** |
|
64 | * Indicates whether this operation supports a parameter. |
||
65 | * |
||
66 | * @param $key The name of a parameter |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function hasParam(string $key): bool |
||
74 | |||
75 | 1 | /** |
|
76 | * @param $name |
||
77 | * |
||
78 | * @return Parameter |
||
79 | */ |
||
80 | public function getParam(string $name) |
||
84 | |||
85 | 186 | /** |
|
86 | * @return string |
||
87 | */ |
||
88 | public function getJsonKey(): string |
||
92 | |||
93 | 68 | /** |
|
94 | * A convenience method that will take a generic array of data and convert it into an array of |
||
95 | * {@see Parameter} objects. |
||
96 | * |
||
97 | * @param array $data A generic data array |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | public static function toParamArray(array $data): array |
||
111 | |||
112 | 211 | /** |
|
113 | * This method will validate all of the user-provided values and throw an exception if any |
||
114 | * failures are detected. This is useful for basic sanity-checking before a request is |
||
115 | * serialized and sent to the API. |
||
116 | * |
||
117 | * @param array $userValues The user-defined values |
||
118 | * |
||
119 | * @return bool TRUE if validation passes |
||
120 | * @throws \Exception If validate fails |
||
121 | */ |
||
122 | public function validate(array $userValues): bool |
||
134 | } |
||
135 |