@@ -169,32 +169,32 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | $instance = crc32($driver . serialize($config)); |
172 | - if (!isset(self::$instances[ $instance ])) { |
|
172 | + if (!isset(self::$instances[$instance])) { |
|
173 | 173 | $badPracticeOmeter[$driver] = 1; |
174 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
174 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
175 | 175 | 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); |
176 | 176 | } |
177 | 177 | $class = self::getNamespacePath() . $driver . '\Driver'; |
178 | - try{ |
|
179 | - self::$instances[ $instance ] = new $class($config); |
|
180 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
181 | - }catch(phpFastCacheDriverCheckException $e){ |
|
178 | + try { |
|
179 | + self::$instances[$instance] = new $class($config); |
|
180 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
181 | + } catch (phpFastCacheDriverCheckException $e) { |
|
182 | 182 | $fallback = self::standardizeDriverName($config['fallback']); |
183 | - if($fallback && $fallback !== $driver){ |
|
183 | + if ($fallback && $fallback !== $driver) { |
|
184 | 184 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
185 | - self::$instances[ $instance ] = new $class($config); |
|
186 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
185 | + self::$instances[$instance] = new $class($config); |
|
186 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
187 | 187 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
188 | - }else{ |
|
188 | + } else { |
|
189 | 189 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
190 | 190 | } |
191 | 191 | } |
192 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
192 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
193 | 193 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
194 | 194 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
195 | 195 | } |
196 | 196 | |
197 | - return self::$instances[ $instance ]; |
|
197 | + return self::$instances[$instance]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public static function __callStatic($name, $arguments) |
257 | 257 | { |
258 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
258 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
259 | 259 | |
260 | 260 | return self::getInstance($name, $options); |
261 | 261 | } |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | { |
297 | 297 | if (is_array($name)) { |
298 | 298 | self::$config = array_merge(self::$config, $name); |
299 | - } else if (is_string($name)){ |
|
300 | - self::$config[ $name ] = $value; |
|
301 | - }else{ |
|
299 | + } else if (is_string($name)) { |
|
300 | + self::$config[$name] = $value; |
|
301 | + } else { |
|
302 | 302 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
303 | 303 | } |
304 | 304 | } |
@@ -367,70 +367,70 @@ discard block |
||
367 | 367 | protected static function validateConfig(array $config) |
368 | 368 | { |
369 | 369 | foreach ($config as $configName => $configValue) { |
370 | - switch($configName) |
|
370 | + switch ($configName) |
|
371 | 371 | { |
372 | 372 | case 'itemDetailedDate': |
373 | - if(!is_bool($configValue)){ |
|
373 | + if (!is_bool($configValue)) { |
|
374 | 374 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
375 | 375 | } |
376 | 376 | break; |
377 | 377 | case 'autoTmpFallback': |
378 | - if(!is_bool($configValue)){ |
|
378 | + if (!is_bool($configValue)) { |
|
379 | 379 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
380 | 380 | } |
381 | 381 | break; |
382 | 382 | case 'secureFileManipulation': |
383 | - if(!is_bool($configValue)){ |
|
383 | + if (!is_bool($configValue)) { |
|
384 | 384 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
385 | 385 | } |
386 | 386 | break; |
387 | 387 | case 'ignoreSymfonyNotice': |
388 | - if(!is_bool($configValue)){ |
|
388 | + if (!is_bool($configValue)) { |
|
389 | 389 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
390 | 390 | } |
391 | 391 | break; |
392 | 392 | case 'defaultTtl': |
393 | - if(!is_numeric($configValue)){ |
|
393 | + if (!is_numeric($configValue)) { |
|
394 | 394 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be numeric"); |
395 | 395 | } |
396 | 396 | break; |
397 | 397 | case 'defaultKeyHashFunction': |
398 | - if(!is_string($configValue) && !is_callable($configValue)){ |
|
398 | + if (!is_string($configValue) && !is_callable($configValue)) { |
|
399 | 399 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a valid function name/closure"); |
400 | 400 | } |
401 | 401 | break; |
402 | 402 | case 'securityKey': |
403 | - if(!is_string($configValue)){ |
|
403 | + if (!is_string($configValue)) { |
|
404 | 404 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
405 | 405 | } |
406 | 406 | break; |
407 | 407 | case 'htaccess': |
408 | - if(!is_bool($configValue)){ |
|
408 | + if (!is_bool($configValue)) { |
|
409 | 409 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
410 | 410 | } |
411 | 411 | break; |
412 | 412 | case 'default_chmod': |
413 | - if(!is_int($configValue)){ |
|
413 | + if (!is_int($configValue)) { |
|
414 | 414 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
415 | 415 | } |
416 | 416 | break; |
417 | 417 | case 'path': |
418 | - if(!is_string($configValue)){ |
|
418 | + if (!is_string($configValue)) { |
|
419 | 419 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
420 | 420 | } |
421 | 421 | break; |
422 | 422 | case 'fallback': |
423 | - if(!is_bool($configValue)){ |
|
423 | + if (!is_bool($configValue)) { |
|
424 | 424 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
425 | 425 | } |
426 | 426 | break; |
427 | 427 | case 'limited_memory_each_object': |
428 | - if(!is_int($configValue)){ |
|
428 | + if (!is_int($configValue)) { |
|
429 | 429 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
430 | 430 | } |
431 | 431 | break; |
432 | 432 | case 'compress_data': |
433 | - if(!is_bool($configValue)){ |
|
433 | + if (!is_bool($configValue)) { |
|
434 | 434 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
435 | 435 | } |
436 | 436 | break; |