FillObjectFromArray::fillObjectFromArray()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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