/** * @param object $object The error object * * @return self * * @throws ValidationException */ 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; }
/** * @param object $object The link object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'self') and !property_exists($object, 'related')) { throw new ValidationException('RelationshipLink has to be at least a "self" or "related" link'); } $this->manager = $manager; $this->container = new DataContainer(); if (property_exists($object, 'self')) { if (!is_string($object->self)) { throw new ValidationException('property "self" has to be a string, "' . gettype($object->self) . '" given.'); } $this->container->set('self', strval($object->self)); } if (property_exists($object, 'related')) { if (!is_string($object->related)) { throw new ValidationException('property "related" has to be a string, "' . gettype($object->related) . '" given.'); } $this->container->set('related', strval($object->related)); } if (property_exists($object, 'pagination')) { $this->container->set('pagination', $this->manager->getFactory()->make('Pagination', [$object->pagination, $this->manager])); } }
/** * @param object $object The error object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { 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->manager = $manager; $this->container = new DataContainer(); $this->container->set('type', strval($object->type)); $this->container->set('id', strval($object->id)); if (property_exists($object, 'meta')) { $this->container->set('meta', $this->manager->getFactory()->make('Meta', [$object->meta, $this->manager])); } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_array($object)) { throw new ValidationException('Resources for a collection has to be in an array, "' . gettype($object) . '" given.'); } if (count($object) > 0) { foreach ($object as $resource) { $this->container->set('', $this->parseResource($resource)); } } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Error has to be an object, "' . gettype($object) . '" given.'); } if (property_exists($object, 'id')) { if (!is_string($object->id)) { throw new ValidationException('property "id" has to be a string, "' . gettype($object->id) . '" given.'); } $this->container->set('id', strval($object->id)); } if (property_exists($object, 'links')) { $links = $this->manager->getFactory()->make('ErrorLink', [$this->manager, $this]); $links->parse($object->links); $this->container->set('links', $links); } if (property_exists($object, 'status')) { if (!is_string($object->status)) { throw new ValidationException('property "status" has to be a string, "' . gettype($object->status) . '" given.'); } $this->container->set('status', strval($object->status)); } if (property_exists($object, 'code')) { if (!is_string($object->code)) { throw new ValidationException('property "code" has to be a string, "' . gettype($object->code) . '" given.'); } $this->container->set('code', strval($object->code)); } if (property_exists($object, 'title')) { if (!is_string($object->title)) { throw new ValidationException('property "title" has to be a string, "' . gettype($object->title) . '" given.'); } $this->container->set('title', strval($object->title)); } if (property_exists($object, 'detail')) { if (!is_string($object->detail)) { throw new ValidationException('property "detail" has to be a string, "' . gettype($object->detail) . '" given.'); } $this->container->set('detail', strval($object->detail)); } if (property_exists($object, 'source')) { $source = $this->manager->getFactory()->make('ErrorSource', [$this->manager, $this]); $source->parse($object->source); $this->container->set('source', $source); } 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; }
/** * @param array $resources The resources as array * * @return self * * @throws ValidationException */ public function __construct($resources, FactoryManagerInterface $manager) { if (!is_array($resources)) { throw new ValidationException('Resources for a collection has to be in an array, "' . gettype($resources) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); if (count($resources) > 0) { foreach ($resources as $resource) { $this->container->set('', $this->parseResource($resource)); } } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Meta has to be an object, "' . gettype($object) . '" given.'); } $object_vars = get_object_vars($object); if (count($object_vars) === 0) { return $this; } foreach ($object_vars as $name => $value) { $this->container->set($name, $value); } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($errors) { if (!is_array($errors)) { throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($errors) . '" given.'); } if (count($errors) === 0) { throw new ValidationException('Errors array cannot be empty and MUST have at least one object'); } foreach ($errors as $err) { $error = $this->manager->getFactory()->make('Error', [$this->manager, $this]); $error->parse($err); $this->container->set('', $error); } return $this; }
/** * @param array $resources The resources as array * * @return self * * @throws ValidationException */ public function __construct($errors, FactoryManagerInterface $manager) { if (!is_array($errors)) { throw new ValidationException('Errors for a collection has to be in an array, "' . gettype($errors) . '" given.'); } if (count($errors) === 0) { throw new ValidationException('Errors array cannot be empty and MUST have at least one object'); } $this->manager = $manager; $this->container = new DataContainer(); foreach ($errors as $error) { $this->container->set('', $this->manager->getFactory()->make('Error', [$error, $this->manager])); } return $this; }
/** * @param object $object The error object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('Meta has to be an object, "' . gettype($object) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); $object_vars = get_object_vars($object); if (count($object_vars) === 0) { return $this; } foreach ($object_vars as $name => $value) { $this->container->set($name, $value); } return $this; }
/** * Set a link * * @param string $name The Name * @param string $link The Link * * @return self */ protected function set($name, $link) { // Pagination: Keys MUST either be omitted or have a null value to indicate that a particular link is unavailable. if (!is_null($link)) { $this->container->set($name, strval($link)); } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Attributes has to be an object, "' . gettype($object) . '" given.'); } if (property_exists($object, 'type') or property_exists($object, 'id') or property_exists($object, 'relationships') or property_exists($object, 'links')) { throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`'); } $object_vars = get_object_vars($object); if (count($object_vars) === 0) { return $this; } foreach ($object_vars as $name => $value) { $this->container->set($name, $value); } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ 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; }
/** * @param object $object The error object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('Jsonapi has to be an object, "' . gettype($object) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); 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')) { $this->container->set('meta', $this->manager->getFactory()->make('Meta', [$object->meta, $this->manager])); } return $this; }
/** * @param object $object The document body * * @return Document * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Document has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'data') and !property_exists($object, 'meta') and !property_exists($object, 'errors')) { throw new ValidationException('Document MUST contain at least one of the following properties: data, errors, meta'); } if (property_exists($object, 'data') and property_exists($object, 'errors')) { throw new ValidationException('The properties `data` and `errors` MUST NOT coexist in Document.'); } if (property_exists($object, 'data')) { $this->container->set('data', $this->parseData($object->data)); } if (property_exists($object, 'meta')) { $meta = $this->manager->getFactory()->make('Meta', [$this->manager, $this]); $meta->parse($object->meta); $this->container->set('meta', $meta); } if (property_exists($object, 'errors')) { $errors = $this->manager->getFactory()->make('ErrorCollection', [$this->manager, $this]); $errors->parse($object->errors); $this->container->set('errors', $errors); } if (property_exists($object, 'included')) { if (!property_exists($object, 'data')) { throw new ValidationException('If Document does not contain a `data` property, the `included` property MUST NOT be present either.'); } $collection = $this->manager->getFactory()->make('ResourceCollection', [$this->manager, $this]); $collection->parse($object->included); $this->container->set('included', $collection); } if (property_exists($object, 'jsonapi')) { $jsonapi = $this->manager->getFactory()->make('Jsonapi', [$this->manager, $this]); $jsonapi->parse($object->jsonapi); $this->container->set('jsonapi', $jsonapi); } if (property_exists($object, 'links')) { $links = $this->manager->getFactory()->make('DocumentLink', [$this->manager, $this]); $links->parse($object->links); $this->container->set('links', $links); } return $this; }
/** * @param object $object The link object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('Link has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'about')) { throw new ValidationException('ErrorLink MUST contain these properties: about'); } if (!is_string($object->about) and !is_object($object->about)) { throw new ValidationException('Link has to be an object or string, "' . gettype($object->about) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); if (is_string($object->about)) { $this->container->set('about', strval($object->about)); return $this; } $this->container->set('about', $this->manager->getFactory()->make('Link', [$object->about, $this->manager])); }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.'); } if (property_exists($object, 'pointer')) { if (!is_string($object->pointer)) { throw new ValidationException('property "pointer" has to be a string, "' . gettype($object->pointer) . '" given.'); } $this->container->set('pointer', strval($object->pointer)); } if (property_exists($object, 'parameter')) { if (!is_string($object->parameter)) { throw new ValidationException('property "parameter" has to be a string, "' . gettype($object->parameter) . '" given.'); } $this->container->set('parameter', strval($object->parameter)); } return $this; }
/** * @param object $object The error object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('Error has to be an object, "' . gettype($object) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); if (property_exists($object, 'id')) { if (!is_string($object->id)) { throw new ValidationException('property "id" has to be a string, "' . gettype($object->id) . '" given.'); } $this->container->set('id', strval($object->id)); } if (property_exists($object, 'links')) { $this->container->set('links', $this->manager->getFactory()->make('ErrorLink', [$object->links, $this->manager])); } if (property_exists($object, 'status')) { if (!is_string($object->status)) { throw new ValidationException('property "status" has to be a string, "' . gettype($object->status) . '" given.'); } $this->container->set('status', strval($object->status)); } if (property_exists($object, 'code')) { if (!is_string($object->code)) { throw new ValidationException('property "code" has to be a string, "' . gettype($object->code) . '" given.'); } $this->container->set('code', strval($object->code)); } if (property_exists($object, 'title')) { if (!is_string($object->title)) { throw new ValidationException('property "title" has to be a string, "' . gettype($object->title) . '" given.'); } $this->container->set('title', strval($object->title)); } if (property_exists($object, 'detail')) { if (!is_string($object->detail)) { throw new ValidationException('property "detail" has to be a string, "' . gettype($object->detail) . '" given.'); } $this->container->set('detail', strval($object->detail)); } if (property_exists($object, 'source')) { $this->container->set('source', $this->manager->getFactory()->make('ErrorSource', [$object->source, $this->manager])); } if (property_exists($object, 'meta')) { $this->container->set('meta', $this->manager->getFactory()->make('Meta', [$object->meta, $this->manager])); } return $this; }
public function run(DataContainerInterface $applicationData) { if (!file_exists($this->filename)) { throw new ApplicationLayerException($this, 'Cannot found file ' . $this->filename); } include $this->filename; if (!isset(${$this->varInFile}) || !is_array(${$this->varInFile})) { throw new ApplicationLayerException($this, 'The variable <' . $this->varInFile . '> is null or not an array.'); } $applicationData->set($this->key, new DataContainerArrayAdapter(${$this->varInFile})); }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ 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); } if (property_exists($object, 'attributes')) { $attributes = $this->manager->getFactory()->make('Attributes', [$this->manager]); $attributes->parse($object->attributes); $this->container->set('attributes', $attributes); } if (property_exists($object, 'relationships')) { $relationships = $this->manager->getFactory()->make('RelationshipCollection', [$this->manager, $this]); $relationships->parse($object->relationships); $this->container->set('relationships', $relationships); } if (property_exists($object, 'links')) { $link = $this->manager->getFactory()->make('ResourceItemLink', [$this->manager, $this]); $link->parse($object->links); $this->container->set('links', $link); } return $this; }
/** * @param object $object The relationship object * * @return Relationship * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('Relationship has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'links') and !property_exists($object, 'data') and !property_exists($object, 'meta')) { throw new ValidationException('A Relationship object MUST contain at least one of the following properties: links, data, meta'); } $this->manager = $manager; $this->container = new DataContainer(); if (property_exists($object, 'links')) { $this->container->set('links', $this->manager->getFactory()->make('RelationshipLink', [$object->links, $this->manager])); } if (property_exists($object, 'data')) { $this->container->set('data', $this->parseData($object->data)); } if (property_exists($object, 'meta')) { $this->container->set('meta', $this->manager->getFactory()->make('Meta', [$object->meta, $this->manager])); } return $this; }
/** * @param object $object The error source object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('ErrorSource has to be an object, "' . gettype($object) . '" given.'); } $this->manager = $manager; $this->container = new DataContainer(); if (property_exists($object, 'pointer')) { if (!is_string($object->pointer)) { throw new ValidationException('property "pointer" has to be a string, "' . gettype($object->pointer) . '" given.'); } $this->container->set('pointer', strval($object->pointer)); } if (property_exists($object, 'parameter')) { if (!is_string($object->parameter)) { throw new ValidationException('property "parameter" has to be a string, "' . gettype($object->parameter) . '" given.'); } $this->container->set('parameter', strval($object->parameter)); } return $this; }
/** * Set a link * * @param string $name The Name * @param string|object $link The Link * * @return self */ protected function set($name, $link) { if ($name === 'meta') { $this->container->set($name, $this->manager->getFactory()->make('Meta', [$link, $this->manager])); return $this; } // from spec: an object ("link object") which can contain the following members: // - href: a string containing the link's URL. if ($name === 'href' or !is_object($link)) { if (!is_string($link)) { throw new ValidationException('Link has to be an object or string, "' . gettype($link) . '" given.'); } $this->container->set($name, strval($link)); return $this; } // Now $link can only be an object // Create Link object if needed if (!$link instanceof LinkInterface) { $this->container->set($name, $this->manager->getFactory()->make('Link', [$link, $this->manager])); } return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Relationships has to be an object, "' . gettype($object) . '" given.'); } if (property_exists($object, 'type') or property_exists($object, 'id')) { throw new ValidationException('These properties are not allowed in attributes: `type`, `id`'); } $object_vars = get_object_vars($object); if (count($object_vars) === 0) { return $this; } foreach ($object_vars as $name => $value) { if ($this->parent->has('attributes.' . $name)) { throw new ValidationException('"' . $name . '" property cannot be set because it exists already in parents Resource object.'); } $relationship = $this->manager->getFactory()->make('Relationship', [$this->manager, $this]); $relationship->parse($value); $this->container->set($name, $relationship); } return $this; }
/** * @param object $object The object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager, AccessInterface $resource) { if (!is_object($object)) { throw new ValidationException('Relationships has to be an object, "' . gettype($object) . '" given.'); } if (property_exists($object, 'type') or property_exists($object, 'id')) { throw new ValidationException('These properties are not allowed in attributes: `type`, `id`'); } $this->manager = $manager; $this->container = new DataContainer(); $object_vars = get_object_vars($object); if (count($object_vars) === 0) { return $this; } foreach ($object_vars as $name => $value) { // #FIXME: Work here with parent strategy if ($resource->has('attributes.' . $name)) { throw new ValidationException('"' . $name . '" property cannot be set because it exists already in parents Resource object.'); } $this->container->set($name, $this->manager->getFactory()->make('Relationship', [$value, $this->manager])); } return $this; }
/** * Set a link * * @param string $name The name of the link * @param string $link The link * @return self */ private function setLink($name, $link) { if (!is_string($link) and !is_object($link)) { throw new ValidationException('Link attribute has to be an object or string, "' . gettype($link) . '" given.'); } if (is_string($link)) { $this->container->set($name, strval($link)); return $this; } // Now $link can only be an object $link_object = $this->manager->getFactory()->make('Link', [$this->manager, $this]); $link_object->parse($link); $this->container->set($name, $link_object); return $this; }
/** * @param object $object The link object * * @return self * * @throws ValidationException */ public function __construct($object, FactoryManagerInterface $manager) { if (!is_object($object)) { throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'self') and !property_exists($object, 'related')) { throw new ValidationException('RelationshipLink has to be at least a "self" or "related" link'); } $this->manager = $manager; $this->container = new DataContainer(); if (property_exists($object, 'self')) { if (!is_string($object->self)) { throw new ValidationException('property "self" has to be a string, "' . gettype($object->self) . '" given.'); } $this->container->set('self', strval($object->self)); } if (property_exists($object, 'related')) { if (!is_string($object->related)) { throw new ValidationException('property "related" has to be a string, "' . gettype($object->related) . '" given.'); } $this->container->set('related', strval($object->related)); } // Pagination links if (property_exists($object, 'first')) { if (!is_string($object->first) and !is_null($object->first)) { throw new ValidationException('property "first" has to be a string or null, "' . gettype($object->first) . '" given.'); } if (!is_null($object->first)) { $this->container->set('first', strval($object->first)); } } if (property_exists($object, 'last')) { if (!is_string($object->last) and !is_null($object->last)) { throw new ValidationException('property "last" has to be a string or null, "' . gettype($object->last) . '" given.'); } if (!is_null($object->last)) { $this->container->set('last', strval($object->last)); } } if (property_exists($object, 'prev')) { if (!is_string($object->prev) and !is_null($object->prev)) { throw new ValidationException('property "prev" has to be a string or null, "' . gettype($object->prev) . '" given.'); } if (!is_null($object->prev)) { $this->container->set('prev', strval($object->prev)); } } if (property_exists($object, 'next')) { if (!is_string($object->next) and !is_null($object->next)) { throw new ValidationException('property "next" has to be a string or null, "' . gettype($object->next) . '" given.'); } if (!is_null($object->next)) { $this->container->set('next', strval($object->next)); } } }
/** * Set a link * * @param string $name The Name * @param string|object $link The Link * * @return self */ protected function set($name, $link) { if ($name === 'meta') { $meta = $this->manager->getFactory()->make('Meta', [$this->manager, $this]); $meta->parse($link); $this->container->set($name, $meta); return $this; } // every link must be an URL if (!is_string($link)) { throw new ValidationException('Every link attribute has to be a string, "' . gettype($link) . '" given.'); } $this->container->set($name, strval($link)); return $this; }
/** * Parses the data for this element * * @param mixed $object The data * * @return self * * @throws ValidationException */ public function parse($object) { if (!is_object($object)) { throw new ValidationException('Relationship has to be an object, "' . gettype($object) . '" given.'); } if (!property_exists($object, 'links') and !property_exists($object, 'data') and !property_exists($object, 'meta')) { throw new ValidationException('A Relationship object MUST contain at least one of the following properties: links, data, meta'); } if (property_exists($object, 'data')) { $this->container->set('data', $this->parseData($object->data)); } if (property_exists($object, 'meta')) { $meta = $this->manager->getFactory()->make('Meta', [$this->manager, $this]); $meta->parse($object->meta); $this->container->set('meta', $meta); } // Parse 'links' after 'data' if (property_exists($object, 'links')) { $link = $this->manager->getFactory()->make('RelationshipLink', [$this->manager, $this]); $link->parse($object->links); $this->container->set('links', $link); } return $this; }
/** * Set a link * * @param string $name The Name * @param string|object $link The Link * * @return self */ protected function set($name, $link) { // from spec: aA link MUST be represented as either: // - a string containing the link's URL. // - an object ("link object") which can contain the following members: if (!is_object($link) and !is_string($link)) { throw new ValidationException('Link attribute has to be an object or string, "' . gettype($link) . '" given.'); } if (is_string($link)) { $this->container->set($name, strval($link)); return $this; } // Now $link can only be an object $link_object = $this->manager->getFactory()->make('Link', [$this->manager, $this]); $link_object->parse($link); $this->container->set($name, $link_object); return $this; }