ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Config.php
Go to the documentation of this file.
1 <?php
2 
3 namespace League\Flysystem;
4 
5 class Config
6 {
10  protected $settings = [];
11 
15  protected $fallback;
16 
22  public function __construct(array $settings = [])
23  {
24  $this->settings = $settings;
25  }
26 
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 
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 
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 
87  public function set($key, $value)
88  {
89  $this->settings[$key] = $value;
90 
91  return $this;
92  }
93 
101  public function setFallback(Config $fallback)
102  {
103  $this->fallback = $fallback;
104 
105  return $this;
106  }
107 }
settings()
Definition: settings.php:2
getDefault($key, $default)
Try to retrieve a default setting from a config fallback.
Definition: Config.php:70
has($key)
Check if an item exists by key.
Definition: Config.php:51
setFallback(Config $fallback)
Set the fallback.
Definition: Config.php:101
__construct(array $settings=[])
Constructor.
Definition: Config.php:22
$default
Definition: build.php:20
$key
Definition: croninfo.php:18