Completed
Push — master ( ac62eb...633109 )
by Dawid
03:39
created

GenericHydrator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 34
ccs 7
cts 14
cp 0.5
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityManager() 0 3 1
A getMetaData() 0 3 1
A setMode() 0 3 1
A __construct() 0 5 1
A getMode() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Igni\Storage\Hydration;
4
5
use Igni\Storage\EntityManager;
6
use Igni\Storage\Mapping\MetaData\EntityMetaData;
7
8
abstract class GenericHydrator implements ObjectHydrator
9
{
10
    protected $entityManager;
11
    protected $metaData;
12
    protected $mode;
13
14 21
    public function __construct(EntityManager $entityManager, string $mode = HydrationMode::BY_REFERENCE)
15
    {
16 21
        $this->mode = $mode;
17 21
        $this->entityManager = $entityManager;
18 21
        $this->metaData = $entityManager->getMetaData($this->getEntityClass());
19 21
    }
20
21
    public function setMode(string $mode): void
22
    {
23
        $this->mode = $mode;
24
    }
25
26
    public function getMode(): string
27
    {
28
        return $this->mode;
29
    }
30
31 13
    public function getEntityManager(): EntityManager
32
    {
33 13
        return $this->entityManager;
34
    }
35
36
    public function getMetaData(): EntityMetaData
37
    {
38
        return $this->metaData;
39
    }
40
41
    abstract public static function getEntityClass(): string;
42
}
43