Conditions | 10 |
Paths | 66 |
Total Lines | 33 |
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 |
||
31 | protected function getFiles(array $source) |
||
32 | { |
||
33 | $fileSet = []; |
||
34 | foreach ($source as $set) { |
||
35 | if (!array_key_exists('files', $set)) { |
||
36 | throw new \Exception("`src` must have a `files` option"); |
||
37 | } |
||
38 | |||
39 | if (!array_key_exists('path', $set)) { |
||
40 | $set['path'] = getcwd(); |
||
41 | } |
||
42 | |||
43 | if (!array_key_exists('recursive', $set)) { |
||
44 | $set['recursive'] = false; |
||
45 | } |
||
46 | |||
47 | $paths = is_array($set['path']) ? $set['path'] : [$set['path']]; |
||
48 | $files = is_array($set['files']) ? $set['files'] : [$set['files']]; |
||
49 | foreach ($paths as $path) { |
||
50 | foreach ($files as $file) { |
||
51 | $finder = new Finder(); |
||
52 | $finder->files()->in($path)->name($file); |
||
53 | if (!$set['recursive']) { |
||
54 | $finder->depth('== 0'); |
||
55 | } |
||
56 | |||
57 | $fileSet = $this->appendFileSet($finder, $fileSet); |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | |||
62 | return $fileSet; |
||
63 | } |
||
64 | |||
81 |