EntityHydrationMethod::fromArray()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
c 0
b 0
f 0
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
/*
4
 * This file is part of the XiideaEasyAuditBundle package.
5
 *
6
 * (c) Xiidea <http://www.xiidea.net>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Xiidea\EasyAuditBundle\Traits;
13
14
use Symfony\Component\PropertyAccess\PropertyAccess;
15
16
trait EntityHydrationMethod
17
{
18
    final public function fromArray($data = array())
19
    {
20
        $accessor = PropertyAccess::createPropertyAccessor();
21
22
        foreach ($data as $property => $value) {
23
            if ($accessor->isWritable($this, $property)) {
24
                $accessor->setValue($this, $property, $value);
25
            }
26
        }
27
28
        return $this;
29
    }
30
}
31