public function register(string $name, $define = null, array $map = []): void
    {
        if (isset($this->active[$name])) {
            throw new InvalidArgumentException("Attempted override of existing component: {$name}");
        }

        if ($define instanceof \Closure) {
            $func = $define;
        } elseif (\is_callable($define)) {
            // second argument is a creation function
            $func = \Closure::fromCallable($define);
        } elseif (\is_string($define)) {
            // second argument is a class-name
            $func = $define;
        } elseif (\is_array($define)) {
            $func = $name;
            $map = $define;
        } elseif (null === $define) {
            // first argument is both the component and class-name
            $func = $name;
            $map = [];
        } else {
            throw new InvalidArgumentException('Unexpected argument type for $define: ' . \gettype($define));
        }

        $this->factory[$name] = $func;
        $this->factoryMap[$name] = $map;

        unset($this->values[$name]);
    }