| Conditions | 14 |
| Paths | 44 |
| Total Lines | 48 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 8 | ||
| Bugs | 1 | Features | 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 |
||
| 92 | protected function getCreateFileList(OutputInterface $output) |
||
| 93 | { |
||
| 94 | $dic = $this->getDic(); |
||
| 95 | $sections = ['Database', 'Util', 'Account', 'Api', 'Char', 'Corp', 'Eve', 'Map', 'Server']; |
||
| 96 | $path = $dic['Yapeal.Sql.dir']; |
||
| 97 | if (!is_readable($path)) { |
||
| 98 | if ($output::VERBOSITY_QUIET !== $output->getVerbosity()) { |
||
| 99 | $mess = sprintf('<comment>Could NOT access Sql directory %1$s</comment>', $path); |
||
| 100 | $output->writeln($mess); |
||
| 101 | } |
||
| 102 | return []; |
||
| 103 | } |
||
| 104 | $fileList = []; |
||
| 105 | foreach ($sections as $dir) { |
||
| 106 | if ('Database' === $dir && $this->dropDatabase) { |
||
| 107 | // Add drop database file if requested. |
||
| 108 | $fileList[] = $this->getFpn() |
||
| 109 | ->normalizeFile($path . $dir . '/DropDatabase.sql'); |
||
| 110 | } |
||
| 111 | foreach (new \DirectoryIterator($path . $dir . '/') as $fileInfo) { |
||
| 112 | // Add file path if it's a sql create file. |
||
| 113 | if ($fileInfo->isFile() |
||
| 114 | && 'sql' === $fileInfo->getExtension() |
||
| 115 | && 0 === strpos($fileInfo->getBasename(), 'Create') |
||
| 116 | ) { |
||
| 117 | $fileList[] = $this->getFpn() |
||
| 118 | ->normalizeFile($fileInfo->getPathname()); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | $fileNames = '%1$sCreateCustomTables.sql,%2$sconfig/CreateCustomTables.sql'; |
||
| 123 | $vendorPath = ''; |
||
| 124 | if (!empty($dic['Yapeal.vendorParentDir'])) { |
||
| 125 | $fileNames .= ',%3$sconfig/CreateCustomTables.sql'; |
||
| 126 | $vendorPath = $dic['Yapeal.vendorParentDir']; |
||
| 127 | } |
||
| 128 | /** |
||
| 129 | * @var array $customFiles |
||
| 130 | */ |
||
| 131 | $customFiles = explode(',', sprintf($fileNames, $path, $dic['Yapeal.baseDir'], $vendorPath)); |
||
| 132 | foreach ($customFiles as $fileName) { |
||
| 133 | if (!is_readable($fileName) || !is_file($fileName)) { |
||
| 134 | continue; |
||
| 135 | } |
||
| 136 | $fileList[] = $fileName; |
||
| 137 | } |
||
| 138 | return $fileList; |
||
| 139 | } |
||
| 140 | /** |
||
| 180 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.