HydratableTrait::getHydrator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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