Passed
Push — master ( 456cc4...4a5fe5 )
by Hector Luis
22:19
created

Getter::__get()   A

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
 * @package     Ticaje_Base
8
 * @author      Hector Luis Barrientos <[email protected]>
9
 */
10
11
namespace Ticaje\Base\Traits;
12
13
/**
14
 * Trait Getter
15
 * @package Ticaje\Base\Traits
16
 */
17
trait Getter
18
{
19
    /**
20
     * @param $name
21
     * @return null
22
     * Redefine magic set method so object using an instance of this one can access properties very simple
23
     */
24
    public function __get($name)
25
    {
26
        if (method_exists($this, $name)) {
27
            return $this->$name();
28
        } elseif (property_exists($this, $name)) {
29
            return $this->$name;
30
        }
31
        return null;
32
    }
33
}
34