diff --git a/Q/Orm/Model.php b/Q/Orm/Model.php index bd8fb75..311e85a 100644 --- a/Q/Orm/Model.php +++ b/Q/Orm/Model.php @@ -29,9 +29,9 @@ public function __construct($fields = []) public function __call($name, $args) { $value = method_exists($this, $name); - if($value){ + if ($value) { $value = $this->$value; - }else{ + } else { $value = $this->__properties[$name]; } @@ -39,7 +39,7 @@ public function __call($name, $args) if ($value instanceof \Closure) { - //Reset prevState, since we just opened up a closure + //Get prevState for restoring later, since we just opened up a closure $prevState = $this->prevState(); foreach ($prevState as $k => $v) { if ($k === $name) { @@ -47,7 +47,7 @@ public function __call($name, $args) } } $this->prevState($prevState); - + return ($value)(); } return $value; @@ -58,14 +58,14 @@ public function __call($name, $args) public function __get($name) { $inProps = $this->__properties[$name] ?? null; - if($inProps){ - if($inProps instanceof \Closure){ + if ($inProps) { + if ($inProps instanceof \Closure) { $evaluated = $this->$name(); - return $this->$name(); - }else{ + return $evaluated; + } else { return $inProps; } - } + } } public function __set($name, $value) @@ -73,7 +73,8 @@ public function __set($name, $value) $this->__properties[$name] = $value; } - public function getProps(){ + public function getProps() + { return $this->__properties; }