mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Added numeric check for slug attribut
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Attribut;
|
||||
|
||||
use App\Exception\UnvalidValueException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
@@ -12,16 +14,30 @@ trait SlugAttribut
|
||||
*/
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* @param string $slug
|
||||
*
|
||||
* @throws UnvalidValueException
|
||||
*/
|
||||
public function setSlug(string $slug): void
|
||||
{
|
||||
if (is_numeric($slug)) {
|
||||
throw new UnvalidValueException('A slug must not be numeric!');
|
||||
}
|
||||
$this->slug = $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug(): string
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSlug(): bool
|
||||
{
|
||||
return isset($this->slug);
|
||||
|
Reference in New Issue
Block a user