1 | <?php |
||
15 | class MultipartRequest extends FluentRequest { |
||
16 | |||
17 | /** @var mixed[] */ |
||
18 | protected $multipartParams = []; |
||
19 | |||
20 | /** |
||
21 | * Check the structure of a multipart parameter array. |
||
22 | * |
||
23 | * @param mixed[] $params The multipart parameters to check. |
||
24 | * |
||
25 | * @throws Exception |
||
26 | */ |
||
27 | 2 | protected function checkMultipartParams( $params ) { |
|
28 | 2 | foreach ( $params as $key => $val ) { |
|
29 | 2 | if ( !is_array( $val ) ) { |
|
30 | throw new Exception( "Parameter '$key' must be an array." ); |
||
31 | } |
||
32 | 2 | if ( !in_array( $key, array_keys( $this->getParams() ) ) ) { |
|
33 | 1 | throw new Exception( "Parameter '$key' is not already set on this request." ); |
|
34 | } |
||
35 | 1 | } |
|
36 | 1 | } |
|
37 | |||
38 | /** |
||
39 | * Set all multipart parameters, replacing all existing ones. |
||
40 | * |
||
41 | * Each key of the array passed in here must be the name of a parameter already set on this |
||
42 | * request object. |
||
43 | * |
||
44 | * @param mixed[] $params The multipart parameters to use. |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setMultipartParams( $params ) { |
||
52 | |||
53 | /** |
||
54 | * Add extra multipart parameters. |
||
55 | * |
||
56 | * Each key of the array passed in here must be the name of a parameter already set on this |
||
57 | * request object. |
||
58 | * |
||
59 | * @param mixed[] $params The multipart parameters to add to any already present. |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | 2 | public function addMultipartParams( $params ) { |
|
68 | |||
69 | /** |
||
70 | * Get all multipart request parameters. |
||
71 | * |
||
72 | * @return mixed[] |
||
73 | */ |
||
74 | 1 | public function getMultipartParams() { |
|
77 | } |
||
78 |