/** * Fetch correct thumbnail according to type (medium or large) * * @param Record|Story $record Record for which to fetch the thumbnail * @param string $type Size of the thumbnail * @return null|\PhraseanetSDK\Entity\Subdef * @throws \InvalidArgumentException */ public function fetch($record, $type) { if (!$record instanceof Record && !$record instanceof Story) { throw new \InvalidArgumentException(); } if (!$this->thumbnailMap->hasSubDefinition($type) || $record instanceof Story) { return $record->getThumbnail(); } $subdefinition = $this->thumbnailMap->getSubDefinition($type); if ($record->getSubdefs()->containsKey($subdefinition)) { return $record->getSubdefs()->get($subdefinition); } return $record->getThumbnail(); }
public function testHasDefinitionReturnsFalseWhenDefinitionIsNotMapped() { $map = new DefinitionMap(array('bacon' => 'high-res')); $this->assertFalse($map->hasSubDefinition('milk')); }