Completed
Push — master ( d83125...6fd519 )
by Michael
01:34
created

MethodPropertyAccess::__isset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Iatstuti\Support\Traits;
4
5
/**
6
 * Allow access to class methods as properties.
7
 *
8
 * @package     Iatstuti\Support
9
 * @copyright   2016 IATSTUTI
10
 * @author      Michael Dyrynda <[email protected]>
11
 */
12
trait MethodPropertyAccess
13
{
14
15
    /**
16
     * Overload the __isset method to correctly handle isset request.
17
     *
18
     * @return bool
19
     */
20
    public function __isset($key)
21
    {
22
        return method_exists($this, $key);
23
    }
24
25
26
    /**
27
     * Overload the __get method to allow property access of methods.
28
     *
29
     * @param  string $key
30
     *
31
     * @return mixed
32
     */
33
    public function __get($key)
34
    {
35
        if (method_exists($this, $key)) {
36
            return $this->{$key}();
37
        }
38
    }
39
}
40