Completed
Push — master ( 38f40f...304183 )
by Ryuichi
05:24
created

EntityProperty::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace WebStream\Database;
3
4
/**
5
 * EntityPropertyクラス
6
 * @author Ryuichi Tanaka
7
 * @since 2017/05/29
8
 * @version 0.7
9
 */
10
trait EntityProperty
11
{
12
    /**
13
     * overload setter
14
     */
15 6
    public function __set($name, $value)
16
    {
17 6
        if (property_exists($this, $name)) {
18 6
            $this->{$name} = $value;
19
        }
20
    }
21
22
    /**
23
     * overload getter
24
     */
25 6
    public function __get($name)
26
    {
27 6
        if (property_exists($this, $name)) {
28 6
            return $this->{$name};
29
        }
30
31
        return null;
32
    }
33
}
34