PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / league / flysystem / src / Config.php

Config.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/league/flysystem/src/Config.php

108 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace League\Flysystem;
4
5 class Config
6 {
7 /**
8 * @var array
9 */
10 protected $settings = [];
11
12 /**
13 * @var Config|null
14 */
15 protected $fallback;
16
17 /**
18 * Constructor.
19 *
20 * @param array $settings
21 */
22 public function __construct(array $settings = [])
23 {
24 $this->settings = $settings;
25 }
26
27 /**
28 * Get a setting.
29 *
30 * @param string $key
31 * @param mixed $default
32 *
33 * @return mixed config setting or default when not found
34 */
35 public function get($key, $default = null)
36 {
37 if ( ! array_key_exists($key, $this->settings)) {
38 return $this->getDefault($key, $default);
39 }
40
41 return $this->settings[$key];
42 }
43
44 /**
45 * Check if an item exists by key.
46 *
47 * @param string $key
48 *
49 * @return bool
50 */
51 public function has($key)
52 {
53 if (array_key_exists($key, $this->settings)) {
54 return true;
55 }
56
57 return $this->fallback instanceof Config
58 ? $this->fallback->has($key)
59 : false;
60 }
61
62 /**
63 * Try to retrieve a default setting from a config fallback.
64 *
65 * @param string $key
66 * @param mixed $default
67 *
68 * @return mixed config setting or default when not found
69 */
70 protected function getDefault($key, $default)
71 {
72 if ( ! $this->fallback) {
73 return $default;
74 }
75
76 return $this->fallback->get($key, $default);
77 }
78
79 /**
80 * Set a setting.
81 *
82 * @param string $key
83 * @param mixed $value
84 *
85 * @return $this
86 */
87 public function set($key, $value)
88 {
89 $this->settings[$key] = $value;
90
91 return $this;
92 }
93
94 /**
95 * Set the fallback.
96 *
97 * @param Config $fallback
98 *
99 * @return $this
100 */
101 public function setFallback(Config $fallback)
102 {
103 $this->fallback = $fallback;
104
105 return $this;
106 }
107 }
108