Skip to content

Commit

Permalink
refactor: check if attr is valid on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
epessine committed Jun 1, 2024
1 parent 4e27cee commit 4331675
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Attributes/Vessel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(...));

Expand All @@ -50,7 +59,7 @@ public function boot(): void
});
});
</script>
HTML, $this->getVesselClass().'-'.$contextId);
HTML, $class.'-'.$contextId);
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4331675

Please sign in to comment.