1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Cecil. |
5
|
|
|
* |
6
|
|
|
* (c) Arnaud Ligny <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Cecil\Renderer; |
15
|
|
|
|
16
|
|
|
use Cecil\Builder; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Config renderer class. |
20
|
|
|
* |
21
|
|
|
* This class implements the \ArrayAccess interface to allow access to configuration |
22
|
|
|
* values using array syntax. It retrieves configuration values from the Builder's |
23
|
|
|
* configuration object, allowing for easy access to configuration settings in a |
24
|
|
|
* language-specific context. |
25
|
|
|
*/ |
26
|
|
|
class Config implements \ArrayAccess |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Builder object. |
30
|
|
|
* @var Builder |
31
|
|
|
*/ |
32
|
|
|
protected $builder; |
33
|
|
|
/** |
34
|
|
|
* Configuration object. |
35
|
|
|
* @var \Cecil\Config |
36
|
|
|
*/ |
37
|
|
|
protected $config; |
38
|
|
|
/** |
39
|
|
|
* Current language code. |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $language; |
43
|
|
|
|
44
|
1 |
|
public function __construct(Builder $builder, string $language) |
45
|
|
|
{ |
46
|
1 |
|
$this->builder = $builder; |
47
|
1 |
|
$this->config = $this->builder->getConfig(); |
48
|
1 |
|
$this->language = $language; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Implement ArrayAccess. |
53
|
|
|
* |
54
|
|
|
* @param mixed $offset |
55
|
|
|
* |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
1 |
|
#[\ReturnTypeWillChange] |
59
|
|
|
public function offsetExists($offset): bool |
60
|
|
|
{ |
61
|
1 |
|
return $this->config->has($offset); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Implements \ArrayAccess. |
66
|
|
|
* |
67
|
|
|
* @param mixed $offset |
68
|
|
|
* |
69
|
|
|
* @return mixed|null |
70
|
|
|
*/ |
71
|
1 |
|
#[\ReturnTypeWillChange] |
72
|
|
|
public function offsetGet($offset) |
73
|
|
|
{ |
74
|
1 |
|
return $this->config->get($offset, $this->language); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Implements \ArrayAccess. |
79
|
|
|
* |
80
|
|
|
* @param mixed $offset |
81
|
|
|
* @param mixed $value |
82
|
|
|
* |
83
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
84
|
|
|
*/ |
85
|
|
|
#[\ReturnTypeWillChange] |
86
|
|
|
public function offsetSet($offset, $value): void |
87
|
|
|
{ |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Implements \ArrayAccess. |
92
|
|
|
* |
93
|
|
|
* @param mixed $offset |
94
|
|
|
* |
95
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
96
|
|
|
*/ |
97
|
|
|
#[\ReturnTypeWillChange] |
98
|
|
|
public function offsetUnset($offset): void |
99
|
|
|
{ |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|