]>
Commit | Line | Data |
---|---|---|
dd883aaf V |
1 | <?php |
2 | ||
b38a1b02 A |
3 | namespace Shaarli; |
4 | ||
5 | use Shaarli\Config\ConfigManager; | |
6 | ||
dd883aaf V |
7 | /** |
8 | * Fake ConfigManager | |
9 | */ | |
b38a1b02 | 10 | class FakeConfigManager extends ConfigManager |
dd883aaf | 11 | { |
44acf706 V |
12 | protected $values = []; |
13 | ||
14 | /** | |
15 | * Initialize with test values | |
16 | * | |
17 | * @param array $values Initial values | |
18 | */ | |
19 | public function __construct($values = []) | |
20 | { | |
21 | $this->values = $values; | |
22 | } | |
23 | ||
24 | /** | |
25 | * Set a given value | |
26 | * | |
27 | * @param string $key Key of the value to set | |
28 | * @param mixed $value Value to set | |
29 | */ | |
b38a1b02 | 30 | public function set($key, $value, $write = false, $isLoggedIn = false) |
44acf706 V |
31 | { |
32 | $this->values[$key] = $value; | |
33 | } | |
34 | ||
35 | /** | |
36 | * Get a given configuration value | |
37 | * | |
38 | * @param string $key Index of the value to retrieve | |
39 | * | |
40 | * @return mixed The value if set, else the name of the key | |
41 | */ | |
b38a1b02 | 42 | public function get($key, $default = '') |
dd883aaf | 43 | { |
44acf706 V |
44 | if (isset($this->values[$key])) { |
45 | return $this->values[$key]; | |
46 | } | |
dd883aaf V |
47 | return $key; |
48 | } | |
704637bf V |
49 | |
50 | /** | |
51 | * Check if a setting exists | |
52 | * | |
53 | * @param string $setting Asked setting, keys separated with dots | |
54 | * | |
55 | * @return bool true if the setting exists, false otherwise | |
56 | */ | |
57 | public function exists($setting) | |
58 | { | |
59 | return array_key_exists($setting, $this->values); | |
60 | } | |
dd883aaf | 61 | } |