mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 20:20:15 +02:00
update deps & install rector
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace DesignPatterns\Behavioral\Memento;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class State
|
||||
{
|
||||
const STATE_CREATED = 'created';
|
||||
@@ -9,24 +11,18 @@ class State
|
||||
const STATE_ASSIGNED = 'assigned';
|
||||
const STATE_CLOSED = 'closed';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $state;
|
||||
private string $state;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private static $validStates = [
|
||||
private static array $validStates = [
|
||||
self::STATE_CREATED,
|
||||
self::STATE_OPENED,
|
||||
self::STATE_ASSIGNED,
|
||||
self::STATE_CLOSED,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
*/
|
||||
public function __construct(string $state)
|
||||
{
|
||||
self::ensureIsValidState($state);
|
||||
@@ -37,7 +33,7 @@ class State
|
||||
private static function ensureIsValidState(string $state)
|
||||
{
|
||||
if (!in_array($state, self::$validStates)) {
|
||||
throw new \InvalidArgumentException('Invalid state given');
|
||||
throw new InvalidArgumentException('Invalid state given');
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user