Art4\JsonApiClient\Jsonapi::parse PHP Method

parse() public method

Parses the data for this element
public parse ( mixed $object ) : self
$object mixed The data
return self
    public function parse($object)
    {
        if (!is_object($object)) {
            throw new ValidationException('Jsonapi has to be an object, "' . gettype($object) . '" given.');
        }
        if (property_exists($object, 'version')) {
            if (is_object($object->version) or is_array($object->version)) {
                throw new ValidationException('property "version" cannot be an object or array, "' . gettype($object->version) . '" given.');
            }
            $this->container->set('version', strval($object->version));
        }
        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;
    }