mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
In between commit Exception refactoring
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Infinito\Attribut;
|
||||
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\Type\InvalidChoiceTypeException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -19,11 +19,12 @@ trait ActionTypeAttribut
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
* @throws InvalidChoiceTypeException
|
||||
*/
|
||||
public function setActionType(string $actionType): void
|
||||
{
|
||||
if (!in_array($actionType, ActionType::getValues())) {
|
||||
throw new NoValidChoiceException('The type is not a valid action type.');
|
||||
throw new InvalidChoiceTypeException('The type is not a valid action type.');
|
||||
}
|
||||
$this->actionType = $actionType;
|
||||
}
|
||||
|
@@ -1,22 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Attribut;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see ClassAttributInterface
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait ClassAttribut
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $class
|
||||
*/
|
||||
public function setClass(string $class): void
|
||||
@@ -26,10 +29,11 @@ trait ClassAttribut
|
||||
|
||||
return;
|
||||
}
|
||||
throw new NotFoundHttpException('Class '.$class.' couldn\'t be found!');
|
||||
throw new NotFoundHttpException('Class ' . $class . ' couldn\'t be found!');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass(): string
|
||||
@@ -38,6 +42,7 @@ trait ClassAttribut
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasClass(): bool
|
||||
|
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace Infinito\Attribut;
|
||||
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
||||
use Infinito\Exception\Type\InvalidChoiceTypeException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @see CrudAttributInterface
|
||||
*/
|
||||
trait CrudAttribut
|
||||
{
|
||||
@@ -23,7 +24,7 @@ trait CrudAttribut
|
||||
public function setCrud(string $crud): void
|
||||
{
|
||||
if (!in_array($crud, CRUDType::getValues())) {
|
||||
throw new NoValidChoiceException();
|
||||
throw new InvalidChoiceTypeException("Value <<$crud>> is no valid choice!");
|
||||
}
|
||||
$this->crud = $crud;
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Infinito\Attribut;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\Exception\NoValidChoiceException;
|
||||
use Infinito\Exception\Type\InvalidChoiceTypeException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -20,14 +20,14 @@ trait LayerAttribut
|
||||
protected $layer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $layer
|
||||
*
|
||||
* @throws NoValidChoiceException
|
||||
* @throws InvalidChoiceTypeException
|
||||
*/
|
||||
public function setLayer(string $layer): void
|
||||
{
|
||||
if (!in_array($layer, LayerType::getValues())) {
|
||||
throw new NoValidChoiceException("'$layer' is not a correct layer type.");
|
||||
throw new InvalidChoiceTypeException("'$layer' is not a correct layer type.");
|
||||
}
|
||||
$this->layer = $layer;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Infinito\Attribut;
|
||||
|
||||
use Infinito\Exception\UnvalidValueException;
|
||||
use Infinito\Exception\Validation\ValueInvalidException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -17,14 +17,15 @@ trait SlugAttribut
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* @todo Maybe throw an other Exception here?
|
||||
* @param string $slug
|
||||
*
|
||||
* @throws UnvalidValueException
|
||||
*
|
||||
* @throws ValueInvalidException
|
||||
*/
|
||||
public function setSlug(string $slug): void
|
||||
{
|
||||
if (is_numeric($slug)) {
|
||||
throw new UnvalidValueException('A slug must not be numeric!');
|
||||
throw new ValueInvalidException('A slug must not be numeric!');
|
||||
}
|
||||
$this->slug = $slug;
|
||||
}
|
||||
|
Reference in New Issue
Block a user