@@ -100,32 +100,32 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $instance = crc32($driver . serialize($config)); |
| 103 | - if (!isset(self::$instances[ $instance ])) { |
|
| 103 | + if (!isset(self::$instances[$instance])) { |
|
| 104 | 104 | $badPracticeOmeter[$driver] = 1; |
| 105 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
| 105 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
| 106 | 106 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', E_USER_NOTICE); |
| 107 | 107 | } |
| 108 | 108 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 109 | - try{ |
|
| 110 | - self::$instances[ $instance ] = new $class($config); |
|
| 111 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 112 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 109 | + try { |
|
| 110 | + self::$instances[$instance] = new $class($config); |
|
| 111 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 112 | + } catch (phpFastCacheDriverCheckException $e) { |
|
| 113 | 113 | $fallback = self::standardizeDriverName($config['fallback']); |
| 114 | - if($fallback && $fallback !== $driver){ |
|
| 114 | + if ($fallback && $fallback !== $driver) { |
|
| 115 | 115 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 116 | - self::$instances[ $instance ] = new $class($config); |
|
| 117 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 116 | + self::$instances[$instance] = new $class($config); |
|
| 117 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 118 | 118 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 119 | - }else{ |
|
| 119 | + } else { |
|
| 120 | 120 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
| 123 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
| 124 | 124 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 125 | 125 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - return self::$instances[ $instance ]; |
|
| 128 | + return self::$instances[$instance]; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public static function __callStatic($name, $arguments) |
| 188 | 188 | { |
| 189 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 189 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 190 | 190 | |
| 191 | 191 | return self::getInstance($name, $options); |
| 192 | 192 | } |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | if (is_array($name)) { |
| 229 | 229 | self::$config = array_merge(self::$config, $name); |
| 230 | - } else if (is_string($name)){ |
|
| 231 | - self::$config[ $name ] = $value; |
|
| 232 | - }else{ |
|
| 230 | + } else if (is_string($name)) { |
|
| 231 | + self::$config[$name] = $value; |
|
| 232 | + } else { |
|
| 233 | 233 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
| 234 | 234 | } |
| 235 | 235 | } |