Conditions | 11 |
Paths | 152 |
Total Lines | 48 |
Code Lines | 32 |
Lines | 22 |
Ratio | 45.83 % |
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 |
||
47 | public static function clear($app, $isAll, $isTwig = false) |
||
48 | { |
||
49 | $cacheDir = $app['config']['root_dir'].'/app/cache'; |
||
50 | |||
51 | $filesystem = new Filesystem(); |
||
52 | $finder = Finder::create()->notName('.gitkeep')->files(); |
||
53 | if ($isAll) { |
||
54 | $finder = $finder->in($cacheDir); |
||
55 | $filesystem->remove($finder); |
||
56 | View Code Duplication | } elseif ($isTwig) { |
|
57 | if (is_dir($cacheDir.'/twig')) { |
||
58 | $finder = $finder->in($cacheDir.'/twig'); |
||
59 | $filesystem->remove($finder); |
||
60 | } |
||
61 | } else { |
||
62 | View Code Duplication | if (is_dir($cacheDir.'/doctrine')) { |
|
63 | $finder = $finder->in($cacheDir.'/doctrine'); |
||
64 | $filesystem->remove($finder); |
||
65 | } |
||
66 | View Code Duplication | if (is_dir($cacheDir.'/profiler')) { |
|
67 | $finder = $finder->in($cacheDir.'/profiler'); |
||
68 | $filesystem->remove($finder); |
||
69 | } |
||
70 | View Code Duplication | if (is_dir($cacheDir.'/twig')) { |
|
71 | $finder = $finder->in($cacheDir.'/twig'); |
||
72 | $filesystem->remove($finder); |
||
73 | } |
||
74 | View Code Duplication | if (is_dir($cacheDir.'/translator')) { |
|
75 | $finder = $finder->in($cacheDir.'/translator'); |
||
76 | $filesystem->remove($finder); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | if (function_exists('opcache_reset')) { |
||
81 | opcache_reset(); |
||
82 | } |
||
83 | |||
84 | if (function_exists('apc_clear_cache')) { |
||
85 | apc_clear_cache('user'); |
||
86 | apc_clear_cache(); |
||
87 | } |
||
88 | |||
89 | if (function_exists('wincache_ucache_clear')) { |
||
90 | wincache_ucache_clear(); |
||
91 | } |
||
92 | |||
93 | return true; |
||
94 | } |
||
95 | } |
||
96 |