| Conditions | 10 |
| Paths | 8 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 49 | protected function setupCacheDriver() |
||
| 50 | { |
||
| 51 | if (EBB_DEV_MODE) { |
||
| 52 | $cacheDriver = new Doctrine\Common\Cache\ArrayCache(); |
||
| 53 | } else { |
||
| 54 | if (EBB_REDIS_CACHE && extension_loaded('redis')) { |
||
| 55 | $redis = new Redis(); |
||
|
|
|||
| 56 | $redis->connect(EBB_REDIS_HOST, EBB_REDIS_PORT); |
||
| 57 | if (EBB_REDIS_PASS) { |
||
| 58 | $redis->auth(EBB_REDIS_PASS); |
||
| 59 | } |
||
| 60 | if (EBB_REDIS_DB) { |
||
| 61 | $redis->select(EBB_REDIS_DB); |
||
| 62 | } |
||
| 63 | $cacheDriver = new Doctrine\Common\Cache\RedisCache(); |
||
| 64 | $cacheDriver->setRedis($redis); |
||
| 65 | } elseif (EBB_APCU_CACHE && extension_loaded('apcu')) { |
||
| 66 | $cacheDriver = new Doctrine\Common\Cache\ApcuCache(); |
||
| 67 | } elseif (EBB_FS_CACHE && is_writable(EBB_CACHE_DIR)) { |
||
| 68 | $cacheDriver = new Doctrine\Common\Cache\FilesystemCache(EBB_CACHE_DIR, '.ebb.data'); |
||
| 69 | } else { |
||
| 70 | $cacheDriver = new Doctrine\Common\Cache\ArrayCache(); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | return $cacheDriver; |
||
| 75 | } |
||
| 77 |