HydratableTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 7 1
A toArray() 0 4 1
A getHydrator() 0 4 1
1
<?php
2
3
namespace Audiens\AppnexusClient\entity;
4
5
use Zend\Hydrator\Reflection;
6
7
trait HydratableTrait
8
{
9
    /**
10
     * @param array $objectArray
11
     *
12
     * @return self
13
     */
14
    public static function fromArray(array $objectArray)
15
    {
16
        $object = new self();
17
        self::getHydrator()->hydrate($objectArray, $object);
18
19
        return $object;
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function toArray()
26
    {
27
        return self::getHydrator()->extract($this);
28
    }
29
30
    /**
31
     * @return Reflection
32
     */
33
    private static function getHydrator()
34
    {
35
        return new Reflection();
36
    }
37
}
38