EntityHydrationMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 13
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 11 3
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