| Conditions | 8 |
| Paths | 41 |
| Total Lines | 106 |
| Code Lines | 77 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 88 | public function execute() |
||
| 89 | { |
||
| 90 | $this->__callOptions(); |
||
| 91 | |||
| 92 | if (empty($this->optionFilename)) { |
||
| 93 | output()->write( |
||
|
|
|||
| 94 | (new Format()) |
||
| 95 | ->setContextualClass(Format::DANGER) |
||
| 96 | ->setString(language()->getLine('CLI_MAKE_MIGRATION_E_FILENAME')) |
||
| 97 | ->setNewLinesAfter(1) |
||
| 98 | ); |
||
| 99 | |||
| 100 | exit(EXIT_ERROR); |
||
| 101 | } |
||
| 102 | |||
| 103 | $className = studlycase($this->optionFilename); |
||
| 104 | |||
| 105 | if(empty($this->optionFileVersion)) { |
||
| 106 | $filename = date('YmdHis') . '_' . underscore($this->optionFilename); |
||
| 107 | } else { |
||
| 108 | $filename = $this->optionFileVersion . '_' . underscore($this->optionFilename); |
||
| 109 | } |
||
| 110 | |||
| 111 | $filePath = PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR; |
||
| 112 | |||
| 113 | if( ! empty($this->optionPath) ) { |
||
| 114 | $filePath = $filePath . $this->optionPath; |
||
| 115 | } |
||
| 116 | |||
| 117 | $filePath = $filePath . $filename; |
||
| 118 | |||
| 119 | $fileDirectory = dirname($filePath) . DIRECTORY_SEPARATOR; |
||
| 120 | |||
| 121 | if ( ! is_dir($fileDirectory)) { |
||
| 122 | mkdir($fileDirectory, 0777, true); |
||
| 123 | } |
||
| 124 | |||
| 125 | if (is_file($filePath)) { |
||
| 126 | output()->write( |
||
| 127 | (new Format()) |
||
| 128 | ->setContextualClass(Format::DANGER) |
||
| 129 | ->setString(language()->getLine('CLI_MAKE_MIGRATION_E_EXISTS', [$filePath])) |
||
| 130 | ->setNewLinesAfter(1) |
||
| 131 | ); |
||
| 132 | |||
| 133 | exit(EXIT_ERROR); |
||
| 134 | } |
||
| 135 | |||
| 136 | $vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
||
| 137 | $vars[ 'BASE_MIGRATION' ] = 'O2System\Framework\Models\Sql\Migration'; |
||
| 138 | |||
| 139 | if($this->optionNoSql) { |
||
| 140 | $vars[ 'BASE_MIGRATION' ] = 'O2System\Framework\Models\NoSql\Migration'; |
||
| 141 | } |
||
| 142 | |||
| 143 | $vars[ 'CLASS' ] = $className; |
||
| 144 | $vars[ 'FILEPATH' ] = $filePath; |
||
| 145 | |||
| 146 | $phpTemplate = <<<PHPTEMPLATE |
||
| 147 | <?php |
||
| 148 | /** |
||
| 149 | * Created by O2System Framework File Generator. |
||
| 150 | * DateTime: CREATE_DATETIME |
||
| 151 | */ |
||
| 152 | |||
| 153 | // ------------------------------------------------------------------------ |
||
| 154 | |||
| 155 | use BASE_MIGRATION |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Class CLASS |
||
| 159 | */ |
||
| 160 | class CLASS extends Migration |
||
| 161 | { |
||
| 162 | /** |
||
| 163 | * CLASS::up |
||
| 164 | */ |
||
| 165 | public function up() |
||
| 166 | { |
||
| 167 | // TODO: Change the autogenerated stub |
||
| 168 | } |
||
| 169 | |||
| 170 | // ------------------------------------------------------------------------ |
||
| 171 | |||
| 172 | /** |
||
| 173 | * CLASS::down |
||
| 174 | */ |
||
| 175 | public function down() |
||
| 176 | { |
||
| 177 | // TODO: Change the autogenerated stub |
||
| 178 | } |
||
| 179 | } |
||
| 180 | PHPTEMPLATE; |
||
| 181 | |||
| 182 | $fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate); |
||
| 183 | file_put_contents($filePath, $fileContent); |
||
| 184 | |||
| 185 | if (is_file($filePath)) { |
||
| 186 | output()->write( |
||
| 187 | (new Format()) |
||
| 188 | ->setContextualClass(Format::SUCCESS) |
||
| 189 | ->setString(language()->getLine('CLI_MAKE_MIGRATION_S_MAKE', [$filePath])) |
||
| 190 | ->setNewLinesAfter(1) |
||
| 191 | ); |
||
| 192 | |||
| 193 | exit(EXIT_SUCCESS); |
||
| 194 | } |
||
| 196 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.