1 | <?php |
||
5 | class HipChatFile |
||
6 | { |
||
7 | /** |
||
8 | * The HipChat room identifier. |
||
9 | * |
||
10 | * @var int|string |
||
11 | */ |
||
12 | public $room; |
||
13 | |||
14 | /** |
||
15 | * Message content that is sent along with the file. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $content = ''; |
||
20 | |||
21 | /** |
||
22 | * File content. |
||
23 | * Can be a resource, stream, string. |
||
24 | * |
||
25 | * @var mixed |
||
26 | */ |
||
27 | public $fileContent; |
||
28 | |||
29 | /** |
||
30 | * A new file name for the file. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | public $fileName = ''; |
||
35 | |||
36 | /** |
||
37 | * A valid mime type of the file content. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public $fileType = ''; |
||
42 | |||
43 | /** |
||
44 | * Create an instance of HipChatFile. |
||
45 | * |
||
46 | * @param string $path |
||
47 | */ |
||
48 | 15 | public function __construct($path = '') |
|
54 | |||
55 | /** |
||
56 | * Create an instance of HipChatFile. |
||
57 | * |
||
58 | * @param string $path |
||
59 | * @return static |
||
60 | */ |
||
61 | 13 | public static function create($path = '') |
|
65 | |||
66 | /** |
||
67 | * Set the HipChat room to share the file in. |
||
68 | * |
||
69 | * @param string|int $room |
||
70 | * @return $this |
||
71 | */ |
||
72 | 1 | public function room($room) |
|
78 | |||
79 | /** |
||
80 | * Set the content of the message. |
||
81 | * |
||
82 | * @param string $content |
||
83 | * @return $this |
||
84 | */ |
||
85 | 5 | public function content($content) |
|
91 | |||
92 | /** |
||
93 | * Alias for content(). |
||
94 | * |
||
95 | * @param string $text |
||
96 | * @return $this |
||
97 | */ |
||
98 | 2 | public function text($text) |
|
102 | |||
103 | /** |
||
104 | * Set the file path. |
||
105 | * |
||
106 | * @param string $path |
||
107 | * @return $this |
||
108 | */ |
||
109 | 6 | public function path($path) |
|
125 | |||
126 | /** |
||
127 | * Explicitly set the content of the file. |
||
128 | * |
||
129 | * @param $content |
||
130 | * @return $this |
||
131 | */ |
||
132 | 8 | public function fileContent($content) |
|
146 | |||
147 | /** |
||
148 | * Set the new name of the file. |
||
149 | * |
||
150 | * @param string $fileName |
||
151 | * @return $this |
||
152 | */ |
||
153 | 8 | public function fileName($fileName) |
|
159 | |||
160 | /** |
||
161 | * Set the mime type of the file content. |
||
162 | * |
||
163 | * @param string $fileType |
||
164 | * @return $this |
||
165 | */ |
||
166 | 8 | public function fileType($fileType) |
|
172 | |||
173 | /** |
||
174 | * Get array representation. |
||
175 | * |
||
176 | * @return array |
||
177 | */ |
||
178 | 4 | public function toArray() |
|
187 | |||
188 | /** |
||
189 | * Get the media type from a resource. |
||
190 | * |
||
191 | * @param $resource |
||
192 | * @return string |
||
193 | */ |
||
194 | 1 | protected function getTypeFromResource($resource) |
|
200 | } |
||
201 |