UnderScoredDto   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkPropertyExistence() 0 5 2
A setData() 0 5 3
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Base Infra Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\Contract\Traits;
11
12
/**
13
 * Trait UnderScoredDto
14
 * @package Ticaje\Contract\Traits
15
 */
16
trait UnderScoredDto
17
{
18
    use BaseDto;
19
20
    /**
21
     * @param array $data
22
     * Not intrusive mode, override parent
23
     */
24
    public function setData(array $data)
25
    {
26
        if (is_array($data)) {
0 ignored issues
show
introduced by
The condition is_array($data) is always true.
Loading history...
27
            foreach ($data as $property => $value) {
28
                $this->set($property, $value);
29
            }
30
        }
31
    }
32
33
    /**
34
     * @param $name
35
     * @return bool|string
36
     * Override parent
37
     */
38
    private function checkPropertyExistence($name)
39
    {
40
        $property = substr($name, 3, strlen($name));
41
        $property = $this->unCamelize($property);
42
        return property_exists($this, $property) ? $property : null;
43
    }
44
}
45