src/CacheFactory.php
public static function make($namespace = null, $adapter = null)
    {
        $defaults = isset(static::$config['defaults'])
                  ? static::$config['defaults']
                  : [];

        if (! $adapter) {
            $adapter = isset($defaults['adapter'])
                     ? $defaults['adapter']
                     : static::DEFAULT_ADAPTER;
        }

        if (! isset(static::$config['adapters'][$adapter])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown type adapter of cache "%s".',
                $adapter
            ));
        }
        $config = static::$config['adapters'][$adapter];
        $class  = $config['class'];

        $options = array_merge(
            isset($defaults['options']) ? (array) $defaults['options'] : [],
            isset($config['options'])   ? (array) $config['options']   : []
        );
        if (! $namespace) {
            $namespace = 'default';
        }
        $options['namespace'] = $namespace;

        $cache = new $class($options);
        if (! $cache instanceof AbstractCache) {
            throw new DomainException(sprintf(
                'The class "%s" of adapter "%s" must inherit '
                . 'an "Es\Cache\AbstractCache".',
                $class,
                $adapter
            ));
        }

        return $cache;
    }
public static function make($namespace = null, $adapter = null)
    {
        $defaults = isset(static::$config['defaults'])
                  ? static::$config['defaults']
                  : [];

        if (! $adapter) {
            $adapter = isset($defaults['adapter'])
                     ? $defaults['adapter']
                     : static::DEFAULT_ADAPTER;
        }

        if (! isset(static::$config['adapters'][$adapter])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown type adapter of cache "%s".',
                $adapter
            ));
        }
        $config = static::$config['adapters'][$adapter];
        $class  = $config['class'];

        $options = array_merge(
            isset($defaults['options']) ? (array) $defaults['options'] : [],
            isset($config['options'])   ? (array) $config['options']   : []
        );
        if (! $namespace) {
            $namespace = 'default';
        }
        $options['namespace'] = $namespace;

        $cache = new $class($options);
        if (! $cache instanceof AbstractCache) {
            throw new DomainException(sprintf(
                'The class "%s" of adapter "%s" must inherit '
                . 'an "Es\Cache\AbstractCache".',
                $class,
                $adapter
            ));
        }

        return $cache;
    }
public static function make ( $ namespace = null , $ adapter = null ) { $ defaults = isset ( static :: $ config [ 'defaults' ] ) ? static :: $ config [ 'defaults' ] : [ ] ; if ( ! $ adapter ) { $ adapter = isset ( $ defaults [ 'adapter' ] ) ? $ defaults [ 'adapter' ] : static :: DEFAULT_ADAPTER ; } if ( ! isset ( static :: $ config [ 'adapters' ] [ $ adapter ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Unknown type adapter of cache "%s".' , $ adapter ) ) ; } $ config = static :: $ config [ 'adapters' ] [ $ adapter ] ; $ class = $ config [ 'class' ] ; $ options = array_merge ( isset ( $ defaults [ 'options' ] ) ? ( array ) $ defaults [ 'options' ] : [ ] , isset ( $ config [ 'options' ] ) ? ( array ) $ config [ 'options' ] : [ ] ) ; if ( ! $ namespace ) { $ namespace = 'default' ; } $ options [ 'namespace' ] = $ namespace ; $ cache = new $ class ( $ options ) ; if ( ! $ cache instanceof AbstractCache ) { throw new DomainException ( sprintf ( 'The class "%s" of adapter "%s" must inherit ' . 'an "Es\Cache\AbstractCache".' , $ class , $ adapter ) ) ; } return $ cache ; }
Make the cache adapter.

@param string $namespace Optional; null by default. The namespace
@param string $adapter   Optional; null by default. The type of adapter

@throws \InvalidArgumentException If the given adapter type not specified
in configuration
@throws \DomainException          If the class of specified adapter not
inherit an Es\Cache\Adapter\AbstractCache

@return \Es\Cache\Adapter\AbstractCache The new instance of cache adapter
Make the cache adapter .