1 | <?php |
||
14 | class Multipart |
||
15 | { |
||
16 | /** |
||
17 | * required "name" key mapping to the form field, name |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $name = ''; |
||
21 | |||
22 | /** |
||
23 | * required "contents" key mapping to a StreamInterface|resource|string |
||
24 | * @var (StreamInterface|resource|string) string |
||
25 | */ |
||
26 | protected $contents; |
||
27 | |||
28 | /** |
||
29 | * optional "headers" associative array of custom headers |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $headers; |
||
33 | |||
34 | /** |
||
35 | * optional "filename" key mapping to a string to send as the filename in |
||
36 | * the part. If no "filename" key is present, then no "filename" attribute |
||
37 | * will be added to the part. |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $filename=''; |
||
41 | |||
42 | /** |
||
43 | * Multipart constructor. |
||
44 | * @param string $name required "name" key mapping to the form field, name |
||
45 | * @param (StreamInterface|resource|string) $contents required "contents" key mapping to a StreamInterface|resource|string |
||
46 | * @param string $filename optional "filename" key mapping to a string to send as the filename in |
||
47 | * the part. If no "filename" key is present, then no "filename" attribute |
||
48 | * will be added to the part. |
||
49 | * @param array $headers optional "headers" associative array of custom headers |
||
50 | * @throws \Exception |
||
51 | */ |
||
52 | public function __construct($name, $contents, $filename=null, $headers=[]) |
||
76 | |||
77 | /** |
||
78 | * @return resource|string |
||
79 | */ |
||
80 | public function getContents() |
||
84 | |||
85 | /** |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getFilename() |
||
92 | |||
93 | /** |
||
94 | * @return array|null |
||
95 | */ |
||
96 | public function getHeaders() |
||
100 | |||
101 | /** |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getName() |
||
108 | |||
109 | /** |
||
110 | * Return an associative array for RequestHelper::SetMultipart() |
||
111 | * @return array |
||
112 | */ |
||
113 | public function getMultipartArray() |
||
125 | |||
126 | } |
||
127 |