Issues (63)

Connection/ConfigurationResolver.php (1 issue)

1
<?php
2
3
namespace Bdf\PrimeBundle\Connection;
4
5
use Bdf\Prime\Configuration;
6
use Bdf\Prime\Connection\Configuration\ConfigurationResolverInterface;
7
use Psr\Container\ContainerExceptionInterface;
8
use Psr\Container\ContainerInterface;
9
10
/**
11
 * Allows declaration of configuration custom by connection. Use a default connection if the configuration is not set.
12
 */
13
class ConfigurationResolver implements ConfigurationResolverInterface
14
{
15
    /**
16
     * @var ContainerInterface
17
     */
18
    private $container;
19
20
    /**
21
     * @var string
22
     */
23
    private $id;
24
25
    /**
26
     * ConfigurationResolver constructor.
27
     */
28 12
    public function __construct(ContainerInterface $container, string $id = 'prime.%s_connection.configuration')
29
    {
30 12
        $this->container = $container;
31 12
        $this->id = $id;
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 10
    public function getConfiguration(string $connectionName): ?Configuration
38
    {
39
        try {
40 10
            return $this->container->get(sprintf($this->id, $connectionName));
41
        } catch (ContainerExceptionInterface $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
42
        }
43
44
        return null;
45
    }
46
}
47