Client.php
9 years ago
Exception.php
10 years ago
Result.php
10 years ago
ResultMeta.php
10 years ago
Source.php
10 years ago
Result.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Tinify; |
| 4 | |
| 5 | class Result extends ResultMeta { |
| 6 | protected $data; |
| 7 | |
| 8 | public function __construct($meta, $data) { |
| 9 | $this->meta = $meta; |
| 10 | $this->data = $data; |
| 11 | } |
| 12 | |
| 13 | public function data() { |
| 14 | return $this->data; |
| 15 | } |
| 16 | |
| 17 | public function toBuffer() { |
| 18 | return $this->data; |
| 19 | } |
| 20 | |
| 21 | public function toFile($path) { |
| 22 | return file_put_contents($path, $this->toBuffer()); |
| 23 | } |
| 24 | |
| 25 | public function size() { |
| 26 | return intval($this->meta["content-length"]); |
| 27 | } |
| 28 | |
| 29 | public function mediaType() { |
| 30 | return $this->meta["content-type"]; |
| 31 | } |
| 32 | |
| 33 | public function contentType() { |
| 34 | return $this->mediaType(); |
| 35 | } |
| 36 | } |
| 37 |