Passed
Push — master ( eff73f...ae14df )
by Siim
14:39
created

AbstractDto   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __set() 0 4 2
A __isset() 0 3 1
A __get() 0 7 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 24.01.19
6
 * Time: 16:01
7
 */
8
9
namespace Sf4\Api\Dto;
10
11
use Sf4\Api\Utils\Traits\SerializerTrait;
12
13
abstract class AbstractDto implements DtoInterface
14
{
15
    use SerializerTrait;
16
17
    /**
18
     * @param $name
19
     * @param $value
20
     */
21
    public function __set($name, $value)
22
    {
23
        if (property_exists($this, $name)) {
24
            $this->$name = $value;
25
        }
26
    }
27
28
    /**
29
     * @param $name
30
     * @return bool
31
     */
32
    public function __isset($name)
33
    {
34
        return isset($this->$name);
35
    }
36
37
    /**
38
     * @param $name
39
     * @return mixed|null
40
     */
41
    public function __get($name)
42
    {
43
        if (property_exists($this, $name)) {
44
            return $this->$name;
45
        }
46
47
        return null;
48
    }
49
}
50