mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized Tests and attributes
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Entity\Meta\LawInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see LawAttributInterface
|
||||
*/
|
||||
trait LawAttribut
|
||||
{
|
||||
@@ -14,11 +16,17 @@ trait LawAttribut
|
||||
*/
|
||||
protected $law;
|
||||
|
||||
/**
|
||||
* @param LawInterface $law
|
||||
*/
|
||||
public function setLaw(LawInterface $law): void
|
||||
{
|
||||
$this->law = $law;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LawInterface
|
||||
*/
|
||||
public function getLaw(): LawInterface
|
||||
{
|
||||
return $this->law;
|
||||
|
@@ -7,6 +7,8 @@ use App\Exception\NoValidChoiceException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @see LayerAttributInterface
|
||||
*/
|
||||
trait LayerAttribut
|
||||
{
|
||||
@@ -25,7 +27,7 @@ trait LayerAttribut
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
if (!array_key_exists($layer, LayerType::getChoices())) {
|
||||
throw new NoValidChoiceException();
|
||||
throw new NoValidChoiceException("'$layer' is not a correct layer type.");
|
||||
}
|
||||
$this->layer = $layer;
|
||||
}
|
||||
|
@@ -7,7 +7,13 @@ namespace App\Attribut;
|
||||
*/
|
||||
interface LayerAttributInterface
|
||||
{
|
||||
/**
|
||||
* @param string $layer
|
||||
*/
|
||||
public function setLayer(string $layer): void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLayer(): string;
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Domain\ActionManagement;
|
||||
|
||||
use App\Exception\NoDefaultClassException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
@@ -56,8 +58,10 @@ final class ActionFactoryService extends AbstractActionConstructor implements Ac
|
||||
return $class;
|
||||
}
|
||||
$defaultClass = $this->getActionNamespace($action);
|
||||
|
||||
return $defaultClass;
|
||||
if (class_exists($defaultClass)) {
|
||||
return $defaultClass;
|
||||
}
|
||||
throw new NoDefaultClassException("There is no default substitution class for $class with attributes {layer:\"$layer\",action:\"$action\"}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class NoDefaultClassException extends \Exception
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user