| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function GetImageFromUrl($url) |
||
| 21 | { |
||
| 22 | $allowed_imgs = $this->AllowedContentTypeImages(); |
||
| 23 | |||
| 24 | if ($img_file_handle = fopen($url.$this->imageManipulation, "rb")) |
||
|
|
|||
| 25 | { |
||
| 26 | $img_data = stream_get_contents($img_file_handle); |
||
| 27 | fclose($img_file_handle); |
||
| 28 | $fi = new \finfo(FILEINFO_MIME); |
||
| 29 | |||
| 30 | $image_mime = strstr($fi->buffer($img_data), ';', true); |
||
| 31 | //dd($image_mime); |
||
| 32 | if (isset($allowed_imgs[$image_mime])) |
||
| 33 | { |
||
| 34 | return array( |
||
| 35 | 'data' => $img_data, |
||
| 36 | 'mime' => $image_mime, |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | |||
| 78 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: