forked from danmichaelo/croptool
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.php
More file actions
40 lines (34 loc) · 1.04 KB
/
Copy pathConfig.php
File metadata and controls
40 lines (34 loc) · 1.04 KB
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
<?php
namespace CropTool;
class Config
{
protected $requiredKeys = ['hostname', 'basepath', 'consumerKey', 'consumerSecret', 'jpegtranPath', 'ddjvuPath', 'magickPath', 'gsPath', 'userAgent'];
protected $data;
public function __construct($config_file)
{
$this->data = parse_ini_file($config_file);
if ($this->data === false) {
throw new \RuntimeException('The config.ini file could not be read.');
}
foreach ($this->requiredKeys as $key) {
if (!isset($this->data[$key])) {
throw new \RuntimeException('Required key not found in config file: ' . $key);
}
}
}
public function get($key, $default=null)
{
return $this->has($key) ? $this->data[$key] : $default;
}
public function has($key)
{
return isset($this->data[$key]) && !empty($this->data[$key]);
}
/**
* Get hostname without port
*/
public function getCookieDomain()
{
return explode(':', $this->get('hostname'))[0];
}
}