Reservation fixes
This commit is contained in:
@ -4,6 +4,7 @@ namespace Incoviba\Model\Venta;
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common;
|
||||
use Incoviba\Model;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Reservation extends Common\Ideal\Model
|
||||
{
|
||||
@ -49,7 +50,7 @@ class Reservation extends Common\Ideal\Model
|
||||
|
||||
public function states(): array
|
||||
{
|
||||
if (!isset($this->states)) {
|
||||
if (count($this->states) === 0) {
|
||||
$this->states = $this->runFactory('states');
|
||||
}
|
||||
return $this->states;
|
||||
@ -60,7 +61,11 @@ class Reservation extends Common\Ideal\Model
|
||||
public function currentState(): Model\Venta\Reservation\State
|
||||
{
|
||||
if (!isset($this->currentState)) {
|
||||
$this->currentState = last($this->states());
|
||||
$states = $this->states();
|
||||
if (count($states) === 0) {
|
||||
throw new InvalidArgumentException('States must not be empty');
|
||||
}
|
||||
$this->currentState = last($states);
|
||||
}
|
||||
return $this->currentState;
|
||||
}
|
||||
|
Reference in New Issue
Block a user