Commit 71079e17 authored by Jan Kuchař's avatar Jan Kuchař

fixed after rebase

parent 0c4bb6dd
......@@ -102,7 +102,7 @@ Assert::false(
)
);
// check for invalid completely invalid arguments
// check for completely invalid arguments
Assert::exception(function () use ($orderService) {
$orderService->canDoTransition('invalid', 'non-existing');
}, \LogicException::class);
......
......@@ -38,14 +38,15 @@ final class OrderState extends Enum
/**
* @param string[] $nextAllowedStates
*/
protected function __construct(array $nextAllowedStates)
protected function __construct($scalar, array $nextAllowedStates)
{
parent::__construct($scalar);
$this->nextAllowedStates = $nextAllowedStates;
}
public function canDoTransition(OrderState $nextState): bool
{
return \in_array($nextState->getScalarValue(), $this->nextAllowedStates, TRUE);
return \in_array($nextState->toScalar(), $this->nextAllowedStates, TRUE);
}
......@@ -57,10 +58,10 @@ final class OrderState extends Enum
// again and you will get infinite loop.
return [
self::RECEIVED => new self([self::PROCESSING, self::CANCELLED]),
self::PROCESSING => new self([self::FINISHED]),
self::FINISHED => new self([]),
self::CANCELLED => new self([]),
new self(self::RECEIVED, [self::PROCESSING, self::CANCELLED]),
new self(self::PROCESSING, [self::FINISHED]),
new self(self::FINISHED, []),
new self(self::CANCELLED, []),
];
}
}
......
......@@ -79,7 +79,7 @@ abstract class OrderState extends Enum {
final protected static function provideInstances(): array
{
return [
self::RECEIVED => new class extends OrderState {
new class(self::RECEIVED) extends OrderState {
public function canDoTransition(OrderState $nextState): bool
{
......@@ -89,7 +89,7 @@ abstract class OrderState extends Enum {
},
self::PROCESSING => new class extends OrderState {
new class(self::PROCESSING) extends OrderState {
public function canDoTransition(OrderState $nextState): bool
{
return $nextState === $this::FINISHED();
......@@ -97,7 +97,7 @@ abstract class OrderState extends Enum {
},
self::FINISHED => new class extends OrderState {
new class(self::FINISHED) extends OrderState {
public function canDoTransition(OrderState $nextState): bool
{
......@@ -112,7 +112,7 @@ abstract class OrderState extends Enum {
},
self::CANCELLED => new class extends OrderState {
new class(self::CANCELLED) extends OrderState {
public function canDoTransition(OrderState $nextState): bool
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment