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

MethodPropertyAccess   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __isset() 0 4 1
A __get() 0 6 2
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