mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Renamed domain LayerManagement to Layer
This commit is contained in:
77
application/symfony/src/Domain/Layer/LayerInterfaceMap.php
Normal file
77
application/symfony/src/Domain/Layer/LayerInterfaceMap.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo for performance reasons it could be helpfull to implement lazy loading in the future
|
||||
*/
|
||||
final class LayerInterfaceMap implements LayerInterfaceMapInterface
|
||||
{
|
||||
/**
|
||||
* @var string The abstract class prefix, which will be removed from the interface name
|
||||
*/
|
||||
const ABSTRACT_CLASS_PREFIX = 'Abstract';
|
||||
|
||||
/**
|
||||
* @var string The suffix which will be added to the interface name
|
||||
*/
|
||||
const INTERFACE_SUFFIX = 'Interface';
|
||||
|
||||
/**
|
||||
* @param string $shortClass
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function filterAbstractClassName(string $shortClass): string
|
||||
{
|
||||
if (self::ABSTRACT_CLASS_PREFIX === substr($shortClass, 0, strlen(self::ABSTRACT_CLASS_PREFIX))) {
|
||||
return substr($shortClass, strlen(self::ABSTRACT_CLASS_PREFIX));
|
||||
}
|
||||
|
||||
return $shortClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function addInterfaceSuffix(string $class): string
|
||||
{
|
||||
return $class.self::INTERFACE_SUFFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInterface(string $layer): string
|
||||
{
|
||||
$className = LayerClassMap::getClass($layer);
|
||||
$elements = explode('\\', $className);
|
||||
$shortClass = $elements[count($elements) - 1];
|
||||
$filteredAbstractClass = self::filterAbstractClassName($shortClass);
|
||||
$elements[count($elements) - 1] = self::addInterfaceSuffix($filteredAbstractClass);
|
||||
$interfaceName = implode('\\', $elements);
|
||||
|
||||
return $interfaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllInterfaces(): array
|
||||
{
|
||||
$allInterfaces = [];
|
||||
foreach (LayerType::getValues() as $layer) {
|
||||
$allInterfaces[$layer] = self::getInterface($layer);
|
||||
}
|
||||
|
||||
return $allInterfaces;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user