private function parseChildren() { // Vine adds className+'Id' as an id to the object $class = preg_split("/\\\\/", get_called_class()); $className = strtolower($class[count($class) - 1]); $vineId = $className . 'Id'; $keys = get_object_vars($this->data); foreach ($keys as $key => $value) { if ($key == $vineId) { $this->data->id = $value; } elseif ($key == 'userId') { $this->data->user = User::fromId($value); } elseif ($key == 'postId') { $this->data->post = Post::fromId($value); } elseif ($key == 'created') { $this->data->{$key} = strptime($value); } else { if ($key == 'comments') { $this->data->{$key} = CommentCollection::fromStdClass($value); } else { if ($key == 'likes') { $this->data->{$key} = LikeCollection::fromStdClass($value); } else { if ($key == 'reposts') { $this->data->{$key} = RepostCollection::fromStdClass($value); } else { if ($key == 'tags') { $this->data->{$key} = PureTagCollection::fromStdClass($value); } else { if ($key == 'entities') { $this->data->{$key} = PureEntityCollection::fromStdClass($value); } else { if ($key == 'user') { $this->data->{$key} = User::fromStdClass($value); } } } } } } } } $names = ['user' => 'username', 'post' => 'description', 'comment' => 'comment', 'tag' => 'tag', 'channel' => 'channel', 'notification' => 'notificationTypeId', 'like' => 'postId', 'repost' => 'postId', 'conversation' => 'conversationId', 'message' => 'message']; $nameAttr = isset($names[$className]) ? $names[$className] : 'unknown'; $this->data->name = isset($this->data->{$nameAttr}) ? $this->data->{$nameAttr} : '<Unknown>'; }