FluentGetter::__get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Maestriam\FileSystem\Concerns;
4
5
/**
6
 * "Facilitador" para recuperar as funções getters da classe
7
 */
8
trait FluentGetter
9
{
10
    /**
11
     * Verifica o atributo acessado e vê se tem um get para retorna-la
12
     * 
13
     * @param string $name
14
     * @return mixed
15
     */
16
    public function __get(string $name)
17
    {
18
        $func = 'get' . ucfirst($name);
19
20
        if (! method_exists($this, $func)) {
21
            throw new \Exception("Has not attribute in class");            
22
        }
23
24
        return $this->$func();
25
    }
26
}