Implemented AbstractMap and ActionHttpMethodMap

This commit is contained in:
Kevin Frantz
2019-01-29 20:02:36 +01:00
parent d50a79f912
commit 8e2d79d236
5 changed files with 127 additions and 14 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Domain\MapManagement;
/**
* This class offers the basic functions for managing an 2 dimensional map.
*
* @author kevinfrantz
*/
abstract class AbstractMap implements MapInterface
{
/**
* @param string $index
* @param array|string[] $map
*
* @return array|string[]
*/
protected static function getValuesByIndex(string $index, array $map): array
{
if (array_key_exists($index, $map)) {
return $map[$index];
}
return [];
}
/**
* @param string $value
* @param array|string[] $map
*
* @return array|string[]
*/
protected static function getIndizesByValue(string $value, array $map): array
{
$result = [];
foreach ($map as $index => $values) {
if (in_array($value, $values)) {
$result[] = $index;
}
}
return $result;
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Domain\MapManagement;
/**
* @author kevinfrantz
*/
interface MapInterface
{
}