DbalModule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * This file is part of the Ray.DbalModule package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace Ray\DbalModule;
8
9
use Doctrine\Common\Annotations\AnnotationRegistry;
10
use Doctrine\DBAL\Driver\Connection;
11
use Ray\DbalModule\Annotation\DbalConfig;
12
use Ray\Di\AbstractModule;
13
use Ray\Di\Name;
14
use Ray\Di\Scope;
15
16
class DbalModule extends AbstractModule
17
{
18
    /**
19
     * @var string
20
     */
21
    private $config;
22
23
    /**
24
     * @var string
25
     */
26
    private $qualifier;
27
28
    /**
29
     * @param AbstractModule $config
30
     * @param string         $qualifier
31
     */
32 2
    public function __construct($config, $qualifier = Name::ANY)
33
    {
34 2
        $this->config = $config;
0 ignored issues
show
Documentation Bug introduced by
It seems like $config of type object<Ray\Di\AbstractModule> is incompatible with the declared type string of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
35 2
        $this->qualifier = $qualifier;
36 2
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    protected function configure()
42
    {
43 2
        AnnotationRegistry::registerFile(__DIR__ . '/DoctrineAnnotations.php');
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...egistry::registerFile() has been deprecated with message: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44 2
        $this->bind()->annotatedWith($this->qualifier)->annotatedWith(DbalConfig::class)->toInstance($this->config);
45 2
        $this->bind(Connection::class)->annotatedWith($this->qualifier)->toProvider(DbalProvider::class, $this->qualifier)->in(Scope::SINGLETON);
46 2
    }
47
}
48