ab3868e18f236b8d14c2c25331fe1690e3971b1c
[phancap.git] / src / phancap / Image.php
1 <?php
2 namespace phancap;
3
4 class Image
5 {
6     protected $config;
7     public $name;
8
9
10     public function __construct($name)
11     {
12         $this->name = $name;
13     }
14
15     public function getMimeType()
16     {
17         $ext = substr($this->name, -4);
18         if ($ext == '.jpg') {
19             return 'image/jpeg';
20         } else if ($ext == '.png') {
21             return 'image/png';
22         } else  if ($ext == '.png') {
23             return 'application/pdf';
24         }
25         return 'application/octet-stream';
26     }
27
28     public function getPath()
29     {
30         return $this->config->cacheDir . $this->name;
31     }
32
33     public function getUrl()
34     {
35         return $this->config->cacheDirUrl . $this->name;
36     }
37
38     public function setConfig(Config $config)
39     {
40         $this->config = $config;
41     }
42 }
43 ?>