protected function configureOptions(array $optionsArray): OptionCollection
    {
        $options = new OptionCollection\ArrayOptionCollection();
        foreach ($optionsArray as $key => $option) {
            if ($key === OptionRepository::PREFIX) {
                continue;
            }

            if ($option instanceof Option) {
                $options->add($option);
                continue;
            }

            if (is_callable($option)) {
                $option = $option($this->config);
            }

            if (is_string($option)) {
                $option = new $option();
            }

            if (! $option instanceof Option) {
                throw InvalidOption::fromOption($option);
            }

            $options->add($option);
        }

        return $options;
    }