infinito/application/symfony/src/Attribut/LayerAttribut.php

43 lines
756 B
PHP
Raw Normal View History

2018-09-21 15:48:23 +02:00
<?php
2019-01-20 10:41:58 +01:00
namespace App\Attribut;
2018-09-21 15:48:23 +02:00
2019-01-16 21:47:41 +01:00
use App\DBAL\Types\Meta\Right\LayerType;
use App\Exception\NoValidChoiceException;
2018-09-21 15:48:23 +02:00
/**
* @author kevinfrantz
2019-01-27 18:38:21 +01:00
*
* @see LayerAttributInterface
2018-09-21 15:48:23 +02:00
*/
trait LayerAttribut
{
/**
2019-01-16 21:47:41 +01:00
* @see LayerType
*
2018-09-21 15:48:23 +02:00
* @var string
*/
protected $layer;
2019-01-16 21:47:41 +01:00
/**
* @param string $layer
*
* @throws NoValidChoiceException
*/
2018-09-21 15:48:23 +02:00
public function setLayer(string $layer): void
{
2019-01-16 21:47:41 +01:00
if (!array_key_exists($layer, LayerType::getChoices())) {
2019-01-27 18:38:21 +01:00
throw new NoValidChoiceException("'$layer' is not a correct layer type.");
2019-01-16 21:47:41 +01:00
}
2018-09-21 15:48:23 +02:00
$this->layer = $layer;
}
2019-01-16 21:47:41 +01:00
/**
* @return string
*/
2018-09-21 15:48:23 +02:00
public function getLayer(): string
{
return $this->layer;
}
}