From 27d4954ab9cb316f5698e0ee17bbbe73f48fde60 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 28 Feb 2017 16:44:02 -0500 Subject: [PATCH] Make certain config values optional --- README.md | 1 + src/Pool.php | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1b40987..b26206d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ structure is like so: $config = [ 'driver' => 'null', // null, apcu, redis, memcache, memcached 'connection' => [ + // Optional (For some drivers): // driver setup, see below for the structure for each // driver ], diff --git a/src/Pool.php b/src/Pool.php index 8cbfbfc..9cfcfef 100644 --- a/src/Pool.php +++ b/src/Pool.php @@ -307,11 +307,9 @@ class Pool implements CacheItemPoolInterface, LoggerAwareInterface { { $driver = ucfirst(strtolower($driverConfig['driver'])); $class = __NAMESPACE__ . "\\Driver\\${driver}Driver"; - - if ( ! array_key_exists('options', $driverConfig)) - { - $driverConfig['options'] = []; - } + + $driverConfig['connection'] = $driverConfig['connection'] ?? []; + $driverConfig['options'] = $driverConfig['options'] ?? []; return new $class($driverConfig['connection'], $driverConfig['options']); }