Skip to content

Commit f0bb6d5

Browse files
authored
Merge pull request #504 from Cosmologist/patch-2
Simplify CacheManager::validateConfig
2 parents 374999b + dcac54d commit f0bb6d5

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

src/phpFastCache/CacheManager.php

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -438,21 +438,11 @@ protected static function validateConfig(array $config)
438438
foreach ($config as $configName => $configValue) {
439439
switch ($configName) {
440440
case 'itemDetailedDate':
441-
if (!is_bool($configValue)) {
442-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
443-
}
444-
break;
445441
case 'autoTmpFallback':
446-
if (!is_bool($configValue)) {
447-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
448-
}
449-
break;
450442
case 'secureFileManipulation':
451-
if (!is_bool($configValue)) {
452-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
453-
}
454-
break;
455443
case 'ignoreSymfonyNotice':
444+
case 'htaccess':
445+
case 'compress_data':
456446
if (!is_bool($configValue)) {
457447
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
458448
}
@@ -468,40 +458,22 @@ protected static function validateConfig(array $config)
468458
}
469459
break;
470460
case 'securityKey':
461+
case 'path':
471462
if (!is_string($configValue)) {
472463
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string");
473464
}
474465
break;
475-
case 'htaccess':
476-
if (!is_bool($configValue)) {
477-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
478-
}
479-
break;
480466
case 'default_chmod':
467+
case 'limited_memory_each_object':
481468
if (!is_int($configValue)) {
482469
throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer");
483470
}
484471
break;
485-
case 'path':
486-
if (!is_string($configValue)) {
487-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string");
488-
}
489-
break;
490472
case 'fallback':
491473
if (!is_bool($configValue) && !is_string($configValue)) {
492474
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean or string");
493475
}
494476
break;
495-
case 'limited_memory_each_object':
496-
if (!is_int($configValue)) {
497-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer");
498-
}
499-
break;
500-
case 'compress_data':
501-
if (!is_bool($configValue)) {
502-
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
503-
}
504-
break;
505477
case 'cacheFileExtension':
506478
if (!is_string($configValue)) {
507479
throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean");
@@ -511,7 +483,7 @@ protected static function validateConfig(array $config)
511483
}
512484
if (!in_array($configValue, self::$safeFileExtensions)) {
513485
throw new phpFastCacheInvalidConfigurationException(
514-
"{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions)
486+
"{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions)
515487
);
516488
}
517489
break;

0 commit comments

Comments
 (0)