. */ declare(strict_types=1); namespace SP\Domain\Common\Attributes; use Attribute; use SP\Domain\Common\Models\Model; use ValueError; /** * Class ModelBounded */ #[Attribute(Attribute::TARGET_CLASS)] final readonly class ModelBounded { private const MODEL = Model::class; public function __construct(public string $modelClass) { if (!is_a($this->modelClass, self::MODEL, true)) { throw new ValueError(sprintf('Only an instance of %s is allowed', self::MODEL)); } } }