| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 37 | protected function configure() |
||
| 38 | { |
||
| 39 | $this |
||
| 40 | ->setName('install') |
||
| 41 | ->addOption('magentoVersion', null, InputOption::VALUE_OPTIONAL, 'Magento version') |
||
| 42 | ->addOption( |
||
| 43 | 'magentoVersionByName', |
||
| 44 | null, |
||
| 45 | InputOption::VALUE_OPTIONAL, |
||
| 46 | 'Magento version name instead of order number' |
||
| 47 | ) |
||
| 48 | ->addOption('installationFolder', null, InputOption::VALUE_OPTIONAL, 'Installation folder') |
||
| 49 | ->addOption('dbHost', null, InputOption::VALUE_OPTIONAL, 'Database host') |
||
| 50 | ->addOption('dbUser', null, InputOption::VALUE_OPTIONAL, 'Database user') |
||
| 51 | ->addOption('dbPass', null, InputOption::VALUE_OPTIONAL, 'Database password') |
||
| 52 | ->addOption('dbName', null, InputOption::VALUE_OPTIONAL, 'Database name') |
||
| 53 | ->addOption('dbPort', null, InputOption::VALUE_OPTIONAL, 'Database port', 3306) |
||
| 54 | ->addOption('installSampleData', null, InputOption::VALUE_OPTIONAL, 'Install sample data') |
||
| 55 | ->addOption( |
||
| 56 | 'useDefaultConfigParams', |
||
| 57 | null, |
||
| 58 | InputOption::VALUE_OPTIONAL, |
||
| 59 | 'Use default installation parameters defined in the yaml file' |
||
| 60 | ) |
||
| 61 | ->addOption('baseUrl', null, InputOption::VALUE_OPTIONAL, 'Installation base url') |
||
| 62 | ->addOption( |
||
| 63 | 'replaceHtaccessFile', |
||
| 64 | null, |
||
| 65 | InputOption::VALUE_OPTIONAL, |
||
| 66 | 'Generate htaccess file (for non vhost environment)' |
||
| 67 | ) |
||
| 68 | ->addOption( |
||
| 69 | 'noDownload', |
||
| 70 | null, |
||
| 71 | InputOption::VALUE_NONE, |
||
| 72 | 'If set skips download step. Used when installationFolder is already a Magento installation that has ' . |
||
| 73 | 'to be installed on the given database.' |
||
| 74 | ) |
||
| 75 | ->addOption( |
||
| 76 | 'only-download', |
||
| 77 | null, |
||
| 78 | InputOption::VALUE_NONE, |
||
| 79 | 'Downloads (and extracts) source code' |
||
| 80 | ) |
||
| 81 | ->addOption( |
||
| 82 | 'forceUseDb', |
||
| 83 | null, |
||
| 84 | InputOption::VALUE_OPTIONAL, |
||
| 85 | 'If --noDownload passed, force to use given database if it already exists.' |
||
| 86 | ) |
||
| 87 | ->setDescription('Install magento'); |
||
| 88 | |||
| 89 | $help = <<<HELP |
||
| 90 | * Download Magento by a list of git repos and zip files (mageplus, |
||
| 91 | magelte, official community packages). |
||
| 92 | * Try to create database if it does not exist. |
||
| 93 | * Installs Magento sample data if available (since version 1.2.0). |
||
| 94 | * Starts Magento installer |
||
| 95 | * Sets rewrite base in .htaccess file |
||
| 96 | |||
| 97 | Example of an unattended Magento CE 2.0.0 installation: |
||
| 98 | |||
| 99 | $ n98-magerun.phar install --dbHost="localhost" --dbUser="mydbuser" \ |
||
| 100 | --dbPass="mysecret" --dbName="magentodb" --installSampleData=yes \ |
||
| 101 | --useDefaultConfigParams=yes \ |
||
| 102 | --magentoVersionByName="magento-ce-2.0.0" \ |
||
| 103 | --installationFolder="magento" --baseUrl="http://magento.localdomain/" |
||
| 104 | |||
| 105 | Additionally, with --noDownload option you can install Magento working |
||
| 106 | copy already stored in --installationFolder on the given database. |
||
| 107 | |||
| 108 | See it in action: http://youtu.be/WU-CbJ86eQc |
||
| 109 | |||
| 110 | HELP; |
||
| 111 | $this->setHelp($help); |
||
| 112 | } |
||
| 113 | |||
| 162 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.