/** * Resolve a link to it's resource. * * @param Link $link * * @return Asset|EntryInterface * * @throws \InvalidArgumentException When encountering an unexpected link type. * * @internal */ public function resolveLink(Link $link) { $id = $link->getId(); $type = $link->getLinkType(); switch ($link->getLinkType()) { case 'Entry': return $this->getEntry($id); case 'Asset': return $this->getAsset($id); default: throw new \InvalidArgumentException('Tyring to resolve link for unknown type "' . $type . '".'); } }
/** * @covers Contentful\Delivery\Link::__construct * @covers Contentful\Delivery\Link::getId * @covers Contentful\Delivery\Link::getLinkType */ public function testGetter() { $link = new Link('123', 'Entry'); $this->assertEquals('123', $link->getId()); $this->assertEquals('Entry', $link->getLinkType()); }