Completed
Push — master ( 4c7769...90a6b5 )
by Stephen
05:33
created

BaseModel::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
namespace StarCitizen\Models;
3
4
/**
5
 * Class BaseModel
6
 *
7
 * @package StarCitizen\Models;
8
 */
9
class BaseModel
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $magicProperties = [];
15
16
    /**
17
     * @param array ...$types
18
     *
19
     * @return $this
20
     */
21 2
    public function with(...$types) {
22 2
        foreach ($types as $type) {
23 2
            if (method_exists($this, strtolower($type)))
24 2
                call_user_func([$this, $type]);
25
        }
26
27 2
        return $this;
28
    }
29
30
    /**
31
     * @param $name
32
     *
33
     * @return mixed|null
34
     */
35 4
    public function __get($name)
36
    {
37 4
        if (in_array($name, $this->magicProperties)) {
38 4
            return call_user_func([$this, $name]);
39
        }
40
41 1
        return null;
42
    }
43
}