FOSElasticaBundle/Type/LookupManager.php
Tim Nagel 7d06cc429b dev
2014-05-15 22:55:35 +10:00

36 lines
738 B
PHP

<?php
namespace FOS\ElasticaBundle\Type;
class LookupManager
{
/**
* @var LookupInterface[]
*/
private $lookups = array();
/**
* @param LookupInterface[] $lookups
*/
public function __construct($lookups)
{
foreach ($lookups as $lookup) {
$this->lookups[$lookup->getKey()] = $lookup;
}
}
/**
* @param string $type
* @return LookupInterface
* @throws \InvalidArgumentException
*/
public function getLookup($type)
{
if (!array_key_exists($type, $this->lookups)) {
throw new \InvalidArgumentException(sprintf('Lookup with key "%s" does not exist', $type));
}
return $this->lookups[$type];
}
}