forked from HermanPeeren/releasemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnection.php
More file actions
58 lines (48 loc) · 1.37 KB
/
Copy pathConnection.php
File metadata and controls
58 lines (48 loc) · 1.37 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
<?php
/**
* @package AkeebaReleaseMaker
* @copyright Copyright (c)2012-2021 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\ReleaseMaker\Configuration\Section;
use Akeeba\ReleaseMaker\Configuration\Configuration;
use Akeeba\ReleaseMaker\Configuration\Connection\Configuration as ConnectionConfiguration;
use Akeeba\ReleaseMaker\Contracts\ConfigurationSection;
/**
* Connection configuration section
*
*
* @since 2.0.0
*/
final class Connection implements ConfigurationSection
{
private array $connections = [];
/** @noinspection PhpUnusedParameterInspection */
public function __construct(array $configuration, Configuration $parent)
{
foreach ($configuration as $key => $definition)
{
$this->connections[$key] = ConnectionConfiguration::factory($definition);
}
}
public function getConnection(string $name): ConnectionConfiguration
{
if (!array_key_exists($name, $this->connections))
{
throw new \OutOfBoundsException(sprintf('Connection ‘%s’ not found in configuration.', $name));
}
return $this->connections[$name];
}
public function getConnectionKeys(): array
{
return array_keys($this->connections);
}
public function __get($name)
{
return $this->getConnection($name);
}
public function __isset($name)
{
return array_key_exists($name, $this->connections);
}
}