diff --git a/src/Attributes/Vessel.php b/src/Attributes/Vessel.php index 96ccde2..7cd501b 100644 --- a/src/Attributes/Vessel.php +++ b/src/Attributes/Vessel.php @@ -26,6 +26,15 @@ public function __construct() public function boot(): void { + $class = $this->getVesselClass(); + + if (! is_a($class, BaseVessel::class, true)) { + throw new BadVesselMethodException( + $this->component->getName(), + $this->getName(), + ); + } + off('__get', $this->handleMagicGet(...)); on('__get', $this->handleMagicGet(...)); @@ -50,7 +59,7 @@ public function boot(): void }); }); - HTML, $this->getVesselClass().'-'.$contextId); + HTML, $class.'-'.$contextId); } /** @@ -114,16 +123,7 @@ protected function getVesselClass(): string protected function getVessel(): object { - $class = $this->getVesselClass(); - - if (! is_a($class, BaseVessel::class, true)) { - throw new BadVesselMethodException( - $this->component->getName(), - $this->getName(), - ); - } - - return new $class($this->component); + return new ($this->getVesselClass())($this->component); } public function getName(): string