Failed Conditions
Push — master ( d8d7f6...ee5f34 )
by Jonathan
11s
created

ConnectionConfigurationLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A chosen() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Configuration\Connection\Loader;
6
7
use Doctrine\DBAL\Connection;
8
use Doctrine\Migrations\Configuration\Configuration;
9
use Doctrine\Migrations\Configuration\Connection\ConnectionLoaderInterface;
10
11
class ConnectionConfigurationLoader implements ConnectionLoaderInterface
12
{
13
    /** @var null|Configuration */
14
    private $configuration;
15
16 38
    public function __construct(?Configuration $configuration = null)
17
    {
18 38
        $this->configuration = $configuration;
19 38
    }
20
21
    /**
22
     * Read the input and return a Configuration, returns null if the config
23
     * is not supported.
24
     */
25 24
    public function chosen() : ?Connection
26
    {
27 24
        if ($this->configuration) {
28 23
            return $this->configuration->getConnection();
29
        }
30
31 1
        return null;
32
    }
33
}
34