Correcciones
This commit is contained in:
@ -13,17 +13,21 @@ class Contract extends Common\Ideal\Model
|
||||
|
||||
public function states(): array
|
||||
{
|
||||
if (!isset($this->states)) {
|
||||
if (!isset($this->states) or count($this->states) === 0) {
|
||||
$this->states = $this->runFactory('states');
|
||||
}
|
||||
return $this->states;
|
||||
}
|
||||
|
||||
protected Contract\State $current;
|
||||
public function currentState(): Contract\State
|
||||
protected ?Contract\State $current;
|
||||
public function currentState(): ?Contract\State
|
||||
{
|
||||
if (!isset($this->current)) {
|
||||
$this->current = last($this->states());
|
||||
try {
|
||||
$this->current = last($this->states());
|
||||
} catch (\TypeError $error) {
|
||||
$this->current = null;
|
||||
}
|
||||
}
|
||||
return $this->current;
|
||||
}
|
||||
@ -38,4 +42,4 @@ class Contract extends Common\Ideal\Model
|
||||
'current' => $this->currentState(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user