FillObjectFromArray   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fillObjectFromArray() 0 6 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Korobovn\CloudPayments\Message\Traits\ModelFeature;
6
7
trait FillObjectFromArray
8
{
9
    /**
10
     * Filling an object from an array
11
     *
12
     * @param array $data
13
     */
14
    public function fillObjectFromArray(array $data): void
15
    {
16
        foreach ($data as $name => $value) {
17
            $setter = sprintf('set%s', ucfirst($name));
18
            if (method_exists($this, $setter)) {
19
                $this->$setter($value);
20
            }
21
        }
22
    }
23
}
24