1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Recca0120\Config\Repositories; |
4
|
|
|
|
5
|
|
|
use ArrayAccess; |
6
|
|
|
use Illuminate\Contracts\Config\Repository; |
7
|
|
|
use Illuminate\Contracts\Foundation\Application; |
8
|
|
|
use Recca0120\Config\Contracts\Repository as RepositoryContract; |
9
|
|
|
|
10
|
|
|
abstract class AbstractRepository implements ArrayAccess, Repository, RepositoryContract |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* $repository. |
14
|
|
|
* |
15
|
|
|
* @var \Illuminate\Contracts\Config\Repository |
16
|
|
|
*/ |
17
|
|
|
protected $repository; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* $app. |
21
|
|
|
* |
22
|
|
|
* @var \Illuminate\Contracts\Foundation\Application |
23
|
|
|
*/ |
24
|
|
|
protected $app; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* __construct. |
28
|
|
|
* |
29
|
|
|
* @param \Illuminate\Contracts\Config\Repository $repository |
30
|
|
|
*/ |
31
|
2 |
|
public function __construct(Repository $repository) |
32
|
|
|
{ |
33
|
2 |
|
$this->repository = $repository; |
34
|
2 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Determine if the given configuration value exists. |
38
|
|
|
* |
39
|
|
|
* @param string $key |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
1 |
|
public function has($key) |
43
|
|
|
{ |
44
|
1 |
|
return $this->repository->has($key); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the specified configuration value. |
49
|
|
|
* |
50
|
|
|
* @param string $key |
51
|
|
|
* @param mixed $default |
52
|
|
|
* @return mixed |
53
|
|
|
*/ |
54
|
1 |
|
public function get($key, $default = null) |
55
|
|
|
{ |
56
|
1 |
|
return $this->repository->get($key, $default); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get all of the configuration items for the application. |
61
|
|
|
* |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
1 |
|
public function all() |
65
|
|
|
{ |
66
|
1 |
|
return $this->repository->all(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Set a given configuration value. |
71
|
|
|
* |
72
|
|
|
* @param array|string $key |
73
|
|
|
* @param mixed $value |
74
|
|
|
*/ |
75
|
1 |
|
public function set($key, $value = null) |
76
|
|
|
{ |
77
|
1 |
|
$this->repository->set($key, $value); |
78
|
1 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Prepend a value onto an array configuration value. |
82
|
|
|
* |
83
|
|
|
* @param string $key |
84
|
|
|
* @param mixed $value |
85
|
|
|
*/ |
86
|
1 |
|
public function prepend($key, $value) |
87
|
|
|
{ |
88
|
1 |
|
return $this->repository->prepend($key, $value); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Push a value onto an array configuration value. |
93
|
|
|
* |
94
|
|
|
* @param string $key |
95
|
|
|
* @param mixed $value |
96
|
|
|
*/ |
97
|
1 |
|
public function push($key, $value) |
98
|
|
|
{ |
99
|
1 |
|
return $this->repository->push($key, $value); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Determine if the given configuration option exists. |
104
|
|
|
* |
105
|
|
|
* @param string $key |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
1 |
|
public function offsetExists($key) |
109
|
|
|
{ |
110
|
1 |
|
return $this->has($key); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get a configuration option. |
115
|
|
|
* |
116
|
|
|
* @param string $key |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
1 |
|
public function offsetGet($key) |
120
|
|
|
{ |
121
|
1 |
|
return $this->get($key); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Set a configuration option. |
126
|
|
|
* |
127
|
|
|
* @param string $key |
128
|
|
|
* @param mixed $value |
129
|
|
|
*/ |
130
|
1 |
|
public function offsetSet($key, $value) |
131
|
|
|
{ |
132
|
1 |
|
$this->set($key, $value); |
133
|
1 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Unset a configuration option. |
137
|
|
|
* |
138
|
|
|
* @param string $key |
139
|
|
|
*/ |
140
|
1 |
|
public function offsetUnset($key) |
141
|
|
|
{ |
142
|
1 |
|
$this->set($key, null); |
143
|
1 |
|
} |
144
|
|
|
} |
145
|
|
|
|