1 | <?php |
||
19 | class Operation |
||
20 | { |
||
21 | /** @var string The HTTP method */ |
||
22 | private $method; |
||
23 | |||
24 | /** @var string The URL path */ |
||
25 | private $path; |
||
26 | |||
27 | /** @var string The top-level JSON key */ |
||
28 | private $jsonKey; |
||
29 | |||
30 | /** @var []Parameter The parameters of this operation */ |
||
31 | private $params; |
||
32 | |||
33 | /** |
||
34 | * @param array $definition The data definition (in array form) that will populate this |
||
35 | * operation. Usually this is retrieved from an {@see ApiInterface} |
||
36 | * object method. |
||
37 | */ |
||
38 | 184 | public function __construct(array $definition) |
|
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | 176 | public function getPath() |
|
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | 176 | public function getMethod() |
|
65 | |||
66 | /** |
||
67 | * Indicates whether this operation supports a parameter. |
||
68 | * |
||
69 | * @param $key The name of a parameter |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | 1 | public function hasParam($key) |
|
77 | |||
78 | /** |
||
79 | * @param $name |
||
80 | * |
||
81 | * @return Parameter |
||
82 | */ |
||
83 | 163 | public function getParam($name) |
|
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | 62 | public function getJsonKey() |
|
95 | |||
96 | /** |
||
97 | * A convenience method that will take a generic array of data and convert it into an array of |
||
98 | * {@see Parameter} objects. |
||
99 | * |
||
100 | * @param array $data A generic data array |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | 184 | public static function toParamArray(array $data) |
|
114 | |||
115 | /** |
||
116 | * This method will validate all of the user-provided values and throw an exception if any |
||
117 | * failures are detected. This is useful for basic sanity-checking before a request is |
||
118 | * serialized and sent to the API. |
||
119 | * |
||
120 | * @param array $userValues The user-defined values |
||
121 | * |
||
122 | * @return bool TRUE if validation passes |
||
123 | * @throws \Exception If validate fails |
||
124 | */ |
||
125 | 180 | public function validate(array $userValues) |
|
139 | |||
140 | 180 | private function checkDisallowedKeys(array $userValues) |
|
148 | } |
||
149 |