diff --git a/src/PhlyRestfully/HalResource.php b/src/PhlyRestfully/HalResource.php index efa110a4..36a50b97 100644 --- a/src/PhlyRestfully/HalResource.php +++ b/src/PhlyRestfully/HalResource.php @@ -34,6 +34,30 @@ public function __construct($resource, $id) $this->id = $id; } + /** + * Check if properties are set + * + * @param string $name + * @throws Exception\InvalidArgumentException + * @return mixed + */ + public function __isset($name) + { + $names = array( + 'resource' => 'resource', + 'id' => 'id', + ); + $name = strtolower($name); + if (!in_array($name, array_keys($names))) { + throw new Exception\InvalidArgumentException(sprintf( + 'Invalid property name "%s"', + $name + )); + } + $prop = $names[$name]; + return $this->{$prop}; + } + /** * Retrieve properties *