src/Charcoal/Cache/CacheBuilder.php
private function resolveOneDriver($driver)
    {
        if (empty($driver)) {
            throw new InvalidArgumentException(
                'Driver is empty'
            );
        }

        if (is_object($driver)) {
            if ($driver instanceof DriverInterface) {
                return $driver;
            } else {
                throw new InvalidArgumentException(sprintf(
                    'Driver class %s must implement %s',
                    get_class($driver),
                    DriverInterface::class
                ));
            }
        }

        $name = $driver;
        if (isset($this->drivers[$name])) {
            $driver = $this->drivers[$name];

            if (empty($driver)) {
                throw new InvalidArgumentException(
                    sprintf('Driver "%s" does not exist', $name)
                );
            }

            if (is_object($driver)) {
                if ($driver instanceof DriverInterface) {
                    return $driver;
                } else {
                    throw new InvalidArgumentException(sprintf(
                        'Driver "%s": Class %s must implement %s',
                        $name,
                        get_class($driver),
                        DriverInterface::class
                    ));
                }
            }
        }

        if (is_a($driver, DriverInterface::class, true)) {
            return new $driver();
        }

        throw new InvalidArgumentException(
            sprintf('Driver "%s" cannot be resolved', $name)
        );
    }
private function resolveOneDriver($driver)
    {
        if (empty($driver)) {
            throw new InvalidArgumentException(
                'Driver is empty'
            );
        }

        if (is_object($driver)) {
            if ($driver instanceof DriverInterface) {
                return $driver;
            } else {
                throw new InvalidArgumentException(sprintf(
                    'Driver class %s must implement %s',
                    get_class($driver),
                    DriverInterface::class
                ));
            }
        }

        $name = $driver;
        if (isset($this->drivers[$name])) {
            $driver = $this->drivers[$name];

            if (empty($driver)) {
                throw new InvalidArgumentException(
                    sprintf('Driver "%s" does not exist', $name)
                );
            }

            if (is_object($driver)) {
                if ($driver instanceof DriverInterface) {
                    return $driver;
                } else {
                    throw new InvalidArgumentException(sprintf(
                        'Driver "%s": Class %s must implement %s',
                        $name,
                        get_class($driver),
                        DriverInterface::class
                    ));
                }
            }
        }

        if (is_a($driver, DriverInterface::class, true)) {
            return new $driver();
        }

        throw new InvalidArgumentException(
            sprintf('Driver "%s" cannot be resolved', $name)
        );
    }
private function resolveOneDriver ( $ driver ) { if ( empty ( $ driver ) ) { throw new InvalidArgumentException ( 'Driver is empty' ) ; } if ( is_object ( $ driver ) ) { if ( $ driver instanceof DriverInterface ) { return $ driver ; } else { throw new InvalidArgumentException ( sprintf ( 'Driver class %s must implement %s' , get_class ( $ driver ) , DriverInterface :: class ) ) ; } } $ name = $ driver ; if ( isset ( $ this -> drivers [ $ name ] ) ) { $ driver = $ this -> drivers [ $ name ] ; if ( empty ( $ driver ) ) { throw new InvalidArgumentException ( sprintf ( 'Driver "%s" does not exist' , $ name ) ) ; } if ( is_object ( $ driver ) ) { if ( $ driver instanceof DriverInterface ) { return $ driver ; } else { throw new InvalidArgumentException ( sprintf ( 'Driver "%s": Class %s must implement %s' , $ name , get_class ( $ driver ) , DriverInterface :: class ) ) ; } } } if ( is_a ( $ driver , DriverInterface :: class , true ) ) { return new $ driver ( ) ; } throw new InvalidArgumentException ( sprintf ( 'Driver "%s" cannot be resolved' , $ name ) ) ; }
Resolve the given cache driver, if available.

@param  mixed $driver The name of a registered cache driver,
the class name or instance of a {@see DriverInterface cache driver}.
@throws InvalidArgumentException When passed an invalid or nonexistant driver name, class name, or object.
@return DriverInterface
Resolve the given cache driver if available .