Model   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 35
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 8 2
A with() 0 8 3
1
<?php
2
namespace StarCitizen\Models;
3
4
/**
5
 * Class BaseModel
6
 *
7
 * @package StarCitizen\Models;
8
 */
9
abstract class Model
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
     * @return mixed
33
     * @throws \Exception
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
        throw new \Exception('Property ' . $name . ' does not exist in this class');
42
    }
43
}