forked from wes/phpimageresize
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathConfiguration.php
70 lines (54 loc) · 1.67 KB
/
Configuration.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
class Configuration {
const CACHE_PATH = './cache/';
const REMOTE_PATH = './cache/remote/';
const CACHE_KEY = 'cacheFolder';
const REMOTE_KEY = 'remoteFolder';
const CACHE_MINUTES_KEY = 'cache_http_minutes';
const WIDTH_KEY = 'width';
const HEIGHT_KEY = 'height';
const CONVERT_PATH = 'convert';
private $opts;
public function __construct($opts=array()) {
$sanitized= $this->sanitize($opts);
$defaults = array(
'crop' => false,
'scale' => 'false',
'thumbnail' => false,
'maxOnly' => false,
'canvas-color' => 'transparent',
'output-filename' => false,
self::CACHE_KEY => self::CACHE_PATH,
self::REMOTE_KEY => self::REMOTE_PATH,
'quality' => 90,
'cache_http_minutes' => 20,
'width' => null,
'height' => null);
$this->opts = array_merge($defaults, $sanitized);
}
public function asHash() {
return $this->opts;
}
public function obtainCache() {
return $this->opts[self::CACHE_KEY];
}
public function obtainRemote() {
return $this->opts[self::REMOTE_KEY];
}
public function obtainConvertPath() {
return self::CONVERT_PATH;
}
public function obtainWidth() {
return $this->opts[self::WIDTH_KEY];
}
public function obtainHeight() {
return $this->opts[self::HEIGHT_KEY];
}
public function obtainCacheMinutes() {
return $this->opts[self::CACHE_MINUTES_KEY];
}
private function sanitize($opts) {
if($opts == null) return array();
return $opts;
}
}