Conditions | 18 |
Paths | 19 |
Total Lines | 44 |
Code Lines | 21 |
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 | public function acceptDir($basename, $pathname, $depth) { |
||
32 | // Skip over the assets directory in the site root. |
||
33 | if ($depth == 1 && $basename == ASSETS_DIR) { |
||
34 | return false; |
||
35 | } |
||
36 | |||
37 | // Skip over any lang directories in the top level of the module. |
||
38 | if ($depth == 2 && $basename == self::LANG_DIR) { |
||
39 | return false; |
||
40 | } |
||
41 | |||
42 | // Skip over the vendor directories |
||
43 | if (($depth == 1 || $depth == 2) && $basename == 'vendor') { |
||
44 | return false; |
||
45 | } |
||
46 | |||
47 | // If we're not in testing mode, then skip over any tests directories. |
||
48 | if ($this->getOption('ignore_tests') && $basename == self::TESTS_DIR) { |
||
49 | return false; |
||
50 | } |
||
51 | |||
52 | // Ignore any directories which contain a _manifest_exclude file. |
||
53 | if (file_exists($pathname . '/' . self::EXCLUDE_FILE)) { |
||
54 | return false; |
||
55 | } |
||
56 | |||
57 | // Only include top level module directories which have a configuration |
||
58 | // _config.php file. However, if we're in themes mode then include |
||
59 | // the themes dir without a config file. |
||
60 | $lackingConfig = ( |
||
61 | $depth == 1 |
||
62 | && !($this->getOption('include_themes') && $basename == THEMES_DIR) |
||
63 | && !file_exists($pathname . '/' . self::CONFIG_FILE) |
||
64 | && !file_exists($pathname . '/' . self::CONFIG_DIR) |
||
65 | && $basename !== self::CONFIG_DIR // include a root config dir |
||
66 | && !file_exists("$pathname/../" . self::CONFIG_DIR) // include all paths if a root config dir exists |
||
67 | ); |
||
68 | |||
69 | if ($lackingConfig) { |
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | return parent::acceptDir($basename, $pathname, $depth); |
||
74 | } |
||
75 | |||
77 |