mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-13 02:14:04 +02:00
update deps & install rector
This commit is contained in:
@@ -4,23 +4,14 @@ namespace DesignPatterns\Behavioral\Memento;
|
||||
|
||||
class Memento
|
||||
{
|
||||
/**
|
||||
* @var State
|
||||
*/
|
||||
private $state;
|
||||
private State $state;
|
||||
|
||||
/**
|
||||
* @param State $stateToSave
|
||||
*/
|
||||
public function __construct(State $stateToSave)
|
||||
{
|
||||
$this->state = $stateToSave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State
|
||||
*/
|
||||
public function getState()
|
||||
public function getState(): State
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,10 +7,7 @@ namespace DesignPatterns\Behavioral\Memento;
|
||||
*/
|
||||
class Ticket
|
||||
{
|
||||
/**
|
||||
* @var State
|
||||
*/
|
||||
private $currentState;
|
||||
private State $currentState;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
Reference in New Issue
Block a user