Getter::__get()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 3
nc 3
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Base Trait
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\Contract\Traits;
11
12
/**
13
 * Trait Getter
14
 * @package Ticaje\Contract\Traits
15
 */
16
trait Getter
17
{
18
    /**
19
     * @param $name
20
     * @return null
21
     * Redefine magic set method so object using an instance of this one can access properties very simple
22
     */
23
    public function __get($name)
24
    {
25
        if (method_exists($this, $name)) {
26
            return $this->$name();
27
        } elseif (property_exists($this, $name)) {
28
            return $this->$name;
29
        }
30
        return null;
31
    }
32
}
33