forked from curso-refactoring/phpimageresize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImagePath.php
More file actions
35 lines (27 loc) · 806 Bytes
/
Copy pathImagePath.php
File metadata and controls
35 lines (27 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
class ImagePath {
private $path;
private $valid_http_protocols = array('http', 'https');
public function __construct($url='') {
$this->path = $this->sanitize($url);
}
public function sanitizedPath() {
return $this->path;
}
public function isHttpProtocol() {
return in_array($this->obtainScheme(), $this->valid_http_protocols);
}
public function obtainFileName() {
$finfo = pathinfo($this->path);
list($filename) = explode('?',$finfo['basename']);
return $filename;
}
private function sanitize($path) {
return urldecode($path);
}
private function obtainScheme() {
if ($this->path == '') return '';
$purl = parse_url($this->path);
return $purl['scheme'];
}
}