Conditions | 4 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
36 | public function __call($method, $args) |
||
37 | { |
||
38 | try { |
||
39 | $reflector = new \ReflectionClass(static::class); |
||
40 | } catch (\ReflectionException $e) { |
||
41 | Craft::error( |
||
42 | $e->getMessage(), |
||
43 | __METHOD__ |
||
44 | ); |
||
45 | |||
46 | return null; |
||
47 | } |
||
48 | if (!$reflector->hasProperty($method)) { |
||
49 | throw new InvalidArgumentException("Property {$method} doesn't exist"); |
||
50 | } |
||
51 | $property = $reflector->getProperty($method); |
||
52 | if (empty($args)) { |
||
53 | // Return the property |
||
54 | return $property->getValue(); |
||
55 | } |
||
56 | // Set the property |
||
57 | $property->setValue($this, $args[0]); |
||
58 | |||
59 | // Make it chainable |
||
60 | return $this; |
||
61 | } |
||
63 |