X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FBaseEntity.php;h=065d100fa3245e4332c4842c3c3cfa3fc15ee2f1;hb=d60d2caef6abca991d5f81b4882a8957918ed0c4;hp=1ea3f8a16b2d713360c0c7a2d16645fdc6673d59;hpb=e80d68ba53776bed047d897f52db7e25b35a479d;p=friendica.git diff --git a/src/BaseEntity.php b/src/BaseEntity.php index 1ea3f8a16b..065d100fa3 100644 --- a/src/BaseEntity.php +++ b/src/BaseEntity.php @@ -1,6 +1,6 @@ toArray(); + if (!property_exists($this, $name)) { + throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class); + } + + return $this->$name; } /** - * Returns the current entity as an array - * - * @return array + * @param mixed $name + * @return bool + * @throws HTTPException\InternalServerErrorException */ - public function toArray() + public function __isset($name): bool { - return get_object_vars($this); + if (!property_exists($this, $name)) { + throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class); + } + + return !empty($this->$name); } }