blob: 34c21a78f21b90101764a64c36a9adc26439e874 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<?php
namespace Engelsystem\Config;
class Config
{
/**
* The config values
*
* @var array
*/
protected $data = [];
/**
* @param string|null $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
if (is_null($key)) {
return $this->data;
}
if ($this->has($key)) {
return $this->data[$key];
}
return $default;
}
/**
* @param string|array $key
* @param mixed $value
*/
public function set($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $configKey => $configValue) {
$this->set($configKey, $configValue);
}
return;
}
$this->data[$key] = $value;
}
/**
* @param string $key
* @return bool
*/
public function has($key)
{
return isset($this->data[$key]);
}
/**
* @param string $key
*/
public function remove($key)
{
unset($this->data[$key]);
}
/**
* @param string $key
* @return mixed
*/
public function __get($key)
{
return $this->get($key);
}
/**
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{
$this->set($key, $value);
}
/**
* @param string $key
* @return bool
*/
public function __isset($key)
{
return $this->has($key);
}
/**
* @param string $key
*/
public function __unset($key)
{
$this->remove($key);
}
}
|