diff --git a/Client.php b/Client.php index e12b159..b2f4405 100644 --- a/Client.php +++ b/Client.php @@ -51,16 +51,16 @@ class Client public function __get(string $name) { // TODO: Implement __get() method. - if (method_exists($this, $name)) { + $getter = 'get' . ucfirst($name); + if (method_exists($this, $getter)) { + return $this->$getter(); + } else if (method_exists($this, $name)) { return $this->$name(); - } - - - if (property_exists($this, $name)) { + } else if (property_exists($this, $name)) { return $this->$name; + } else { + throw new Exception('Property|Method "' . $name . '" does not exist.'); } - - throw new Exception('Property|Method "' . $name . '" does not exist.'); } }