public function parse($object)
{
if (!is_object($object)) {
throw new ValidationException('Resource has to be an object, "' . gettype($object) . '" given.');
}
if (!property_exists($object, 'type')) {
throw new ValidationException('A resource object MUST contain a type');
}
if (!property_exists($object, 'id')) {
throw new ValidationException('A resource object MUST contain an id');
}
if (is_object($object->type) or is_array($object->type)) {
throw new ValidationException('Resource type cannot be an array or object');
}
if (is_object($object->id) or is_array($object->id)) {
throw new ValidationException('Resource Id cannot be an array or object');
}
$this->container->set('type', strval($object->type));
$this->container->set('id', strval($object->id));
if (property_exists($object, 'meta')) {
$meta = $this->manager->getFactory()->make('Meta', [$this->manager, $this]);
$meta->parse($object->meta);
$this->container->set('meta', $meta);
}
return $this;
}