mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Implemented Tests for ActionHttpMethodMap
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MapManagement;
|
||||
|
||||
use App\DBAL\Types\ActionType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ActionHttpMethodMap extends AbstractMap implements ActionHttpMethodMapInterface
|
||||
{
|
||||
const ACTION_HTTP_METHOD_MAP = [
|
||||
ActionType::READ => [
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
ActionType::CREATE => [
|
||||
Request::METHOD_POST,
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
ActionType::UPDATE => [
|
||||
Request::METHOD_PUT,
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
ActionType::DELETE => [
|
||||
Request::METHOD_GET,
|
||||
Request::METHOD_DELETE,
|
||||
],
|
||||
ActionType::THREAD => [
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
];
|
||||
|
||||
public static function getActions(string $httpMethod): array
|
||||
{
|
||||
return parent::getIndizesByValue($httpMethod, self::ACTION_HTTP_METHOD_MAP);
|
||||
}
|
||||
|
||||
public static function getHttpMethods(string $action): array
|
||||
{
|
||||
return parent::getValuesByIndex($action, self::ACTION_HTTP_METHOD_MAP);
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\MapManagement;
|
||||
|
||||
/**
|
||||
* This class offers a map for ActionTypes to HttpMethods.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ActionHttpMethodMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $httpMethod
|
||||
*
|
||||
* @return array|string[] The Http-Methods which belong to an action
|
||||
*/
|
||||
public static function getActions(string $httpMethod): array;
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return array|string[] The Http-Methods which are possible for an action
|
||||
*/
|
||||
public static function getHttpMethods(string $action): array;
|
||||
}
|
Reference in New Issue
Block a user