1 | <?php |
||
10 | class File extends AbstractResponse { |
||
11 | |||
12 | /** |
||
13 | * The name of the File from Response |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $fileName; |
||
17 | |||
18 | /** |
||
19 | * File Path for response |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $destinationPath; |
||
23 | |||
24 | public function __construct($curlRequest, $curlResponse = NULL, $destination = NULL){ |
||
28 | |||
29 | /** |
||
30 | * @inheritdoc |
||
31 | * Extract Filename from Headers |
||
32 | * @param mixed $curlResponse |
||
33 | */ |
||
34 | public function setCurlResponse($curlResponse) { |
||
43 | |||
44 | |||
45 | /** |
||
46 | * Configure the Destination path to store the File response |
||
47 | * @param null $destination |
||
48 | * @return self |
||
49 | */ |
||
50 | public function setDestinationPath($destination = NULL){ |
||
57 | |||
58 | /** |
||
59 | * Extract the filename from the Headers, and store it in filename property |
||
60 | */ |
||
61 | protected function extractFileName(){ |
||
69 | |||
70 | /** |
||
71 | * Set the Filename for response to be saved to |
||
72 | * @param $fileName |
||
73 | * @return self |
||
74 | */ |
||
75 | public function setFileName($fileName){ |
||
79 | |||
80 | /** |
||
81 | * Return the filename found in response |
||
82 | * @return mixed |
||
83 | */ |
||
84 | public function getFileName(){ |
||
87 | |||
88 | /** |
||
89 | * Write the downloaded file |
||
90 | * @return string|boolean - False if not written |
||
91 | */ |
||
92 | public function writeFile(){ |
||
106 | |||
107 | /** |
||
108 | * Return the full File path, where Response was stored |
||
109 | * @return string |
||
110 | */ |
||
111 | public function file(){ |
||
114 | |||
115 | } |