for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Yokai\EnumBundle\Registry;
use Yokai\EnumBundle\Enum\EnumInterface;
use Yokai\EnumBundle\Exception\DuplicatedEnumException;
use Yokai\EnumBundle\Exception\InvalidEnumException;
/**
* @author Yann Eugoné <[email protected]>
*/
class EnumRegistry implements EnumRegistryInterface
{
* @var EnumInterface[]
private $enums;
* @inheritdoc
public function add(EnumInterface $enum)
if ($this->has($enum->getName())) {
throw DuplicatedEnumException::alreadyRegistered($enum->getName());
}
$this->enums[$enum->getName()] = $enum;
public function get($name)
if (!$this->has($name)) {
throw InvalidEnumException::nonexistent($name);
return $this->enums[$name];
public function has($name)
return isset($this->enums[$name]);