1 | <?php |
||
24 | class Config implements ConfigInterface, GeneratorInterface |
||
25 | { |
||
26 | /** |
||
27 | * List of preconfigurationured sections |
||
28 | * |
||
29 | * @var array<string, \XL2TP\Interfaces\SectionInterface> |
||
30 | */ |
||
31 | public $sections = []; |
||
32 | |||
33 | /** |
||
34 | * Configuration constructor. |
||
35 | * |
||
36 | * @param array $configuration |
||
37 | */ |
||
38 | 9 | public function __construct(array $configuration = []) |
|
46 | |||
47 | /** |
||
48 | * Get section of configuration by provided name |
||
49 | * |
||
50 | * @param string $section Name of section |
||
51 | * @param string|null $suffix Additional suffix of section name |
||
52 | * |
||
53 | * @return \XL2TP\Interfaces\SectionInterface |
||
54 | */ |
||
55 | 7 | public function section(string $section, string $suffix = null): SectionInterface |
|
68 | |||
69 | /** |
||
70 | * If required section is set |
||
71 | * |
||
72 | * @param string $name |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | 1 | public function __isset(string $name): bool |
|
87 | |||
88 | /** |
||
89 | * Bad method call, not allowed here |
||
90 | * |
||
91 | * @param string $name |
||
92 | * @param string $value |
||
93 | * |
||
94 | * @throws \BadMethodCallException Because method is readonly |
||
95 | */ |
||
96 | 1 | public function __set(string $name, string $value) |
|
100 | |||
101 | /** |
||
102 | * Get section by name |
||
103 | * |
||
104 | * @param string $name |
||
105 | * |
||
106 | * @return \XL2TP\Interfaces\SectionInterface |
||
107 | * @throws \InvalidArgumentException If section is not allowed |
||
108 | */ |
||
109 | 7 | public function __get(string $name): SectionInterface |
|
122 | |||
123 | /** |
||
124 | * Get section by name |
||
125 | * |
||
126 | * @param string $section |
||
127 | * @param array $arguments |
||
128 | * |
||
129 | * @return \XL2TP\Interfaces\SectionInterface |
||
130 | * @throws \InvalidArgumentException If section is not allowed |
||
131 | */ |
||
132 | 1 | public function __call(string $section, array $arguments): SectionInterface |
|
142 | |||
143 | /** |
||
144 | * Generate L2TP configuration by parameters from memory |
||
145 | * |
||
146 | * @return string |
||
147 | * @throws \RuntimeException If was set bad configuration |
||
148 | */ |
||
149 | 1 | public function generate(): string |
|
155 | } |
||
156 |