-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasConfiguration.php
More file actions
61 lines (53 loc) · 1.32 KB
/
Copy pathHasConfiguration.php
File metadata and controls
61 lines (53 loc) · 1.32 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace BabenkoIvan\FluentArray;
trait HasConfiguration
{
/**
* @var FluentArray
*/
protected static $globalConfig;
/**
* @var FluentArray
*/
protected $config;
/**
* The method allows you to set or retrieve global configuration.
* @param FluentArray|null $globalConfig
* @return mixed
*/
public static function globalConfig(FluentArray $globalConfig = null)
{
if (isset($globalConfig)) {
static::$globalConfig = $globalConfig;
} else {
if (!isset(static::$globalConfig)) {
static::$globalConfig = static::defaultConfig();
}
return static::$globalConfig;
}
}
/**
* The method allows you to set or retrieve local configuration.
* @param FluentArray|null $config
* @return mixed
*/
public function config(FluentArray $config = null)
{
if (isset($config)) {
$this->config = $config;
return $this;
} else {
if (!isset($this->config)) {
$this->config = clone static::globalConfig();
}
return $this->config;
}
}
/**
* @return FluentArray
*/
protected static function defaultConfig()
{
return new FluentArray();
}
}