Completed
Push — master ( 28180f...9feb73 )
by Joachim
14:25
created

AbstractEntity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 4 1
A getHydrator() 0 3 1
A extract() 0 4 1
1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Zend\Hydrator\ClassMethods;
6
use Zend\Hydrator\HydratorInterface;
7
8
abstract class AbstractEntity
9
{
10
    public function hydrate(array $data)
11
    {
12
        $hydrator = $this->getHydrator();
13
        $hydrator->hydrate($data, $this);
14
    }
15
16
    public function extract() : array
17
    {
18
        $hydrator = $this->getHydrator();
19
        return $hydrator->extract($this);
20
    }
21
22
    /**
23
     * @return HydratorInterface
24
     */
25
    protected function getHydrator() : HydratorInterface
26
    {
27
        return new ClassMethods();
28
    }
29
}
30