GenericRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php declare(strict_types=1);
2
3
namespace Igni\Storage\Driver;
4
5
use Igni\Storage\EntityManager;
6
use Igni\Storage\Hydration\ObjectHydrator;
7
use Igni\Storage\Mapping\MetaData\EntityMetaData;
8
use Igni\Storage\Repository;
9
10
abstract class GenericRepository implements Repository
11
{
12
    /**
13
     * @var Connection
14
     */
15
    protected $connection;
16
    /**
17
     * @var EntityManager
18
     */
19
    protected $entityManager;
20
    /**
21
     * @var ObjectHydrator
22
     */
23
    protected $hydrator;
24
25
    /**
26
     * @var EntityMetaData
27
     */
28
    protected $metaData;
29
30 22
    public function __construct(EntityManager $entityManager, Connection $connection = null)
31
    {
32 22
        $this->entityManager = $entityManager;
33 22
        $this->metaData = $this->entityManager->getMetaData($this->getEntityClass());
34 22
        $this->hydrator = $this->entityManager->getHydrator($this->getEntityClass());
35 22
        if ($connection === null) {
36 22
            $connection = ConnectionManager::get($this->metaData->getConnection());
37
        }
38 22
        $this->connection = $connection;
39 22
    }
40
}
41