Implemented LayerClassMap

This commit is contained in:
Kevin Frantz 2019-01-26 17:06:29 +01:00
parent 05cd278dab
commit a59d803d96
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace App\Domain\LayerManagement;
use App\DBAL\Types\Meta\Right\LayerType;
use App\Entity\Source\AbstractSource;
use App\Exception\NotSetException;
/**
* @author kevinfrantz
*/
final class LayerClassMap implements LayerClassMapInterface
{
const LAYER_CLASS_MAP = [
LayerType::SOURCE => AbstractSource::class,
];
/**
* @param string $layer
*
* @throws NotSetException
*
* @return string
*/
public static function getClass(string $layer): string
{
if (array_key_exists($layer, self::LAYER_CLASS_MAP)) {
return self::LAYER_CLASS_MAP[$layer];
}
throw new NotSetException('The requested layer is not mapped!');
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Domain\LayerManagement;
/**
* @author kevinfrantz
*/
interface LayerClassMapInterface
{
/**
* @param string $layer
*
* @return string The class which belongs to an Layer
*/
public static function getClass(string $layer): string;
}