| Conditions | 2 |
| Paths | 2 |
| Total Lines | 160 |
| Code Lines | 109 |
| 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 |
||
| 48 | public function boot(ConsoleBootloader $console): void |
||
| 49 | { |
||
| 50 | $console->addCommand(Command\Database\EntityCommand::class, true); |
||
| 51 | $console->addCommand(Command\Database\RepositoryCommand::class, true); |
||
| 52 | $console->addCommand(Command\BootloaderCommand::class); |
||
| 53 | $console->addCommand(Command\CommandCommand::class); |
||
| 54 | $console->addCommand(Command\ConfigCommand::class); |
||
| 55 | $console->addCommand(Command\ControllerCommand::class); |
||
| 56 | $console->addCommand(Command\FilterCommand::class); |
||
| 57 | $console->addCommand(Command\JobHandlerCommand::class); |
||
| 58 | $console->addCommand(Command\MiddlewareCommand::class); |
||
| 59 | $console->addCommand(Command\MigrationCommand::class, true); |
||
| 60 | |||
| 61 | try { |
||
| 62 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
||
| 63 | } catch (ReflectionException $e) { |
||
| 64 | $defaultNamespace = ''; |
||
| 65 | } |
||
| 66 | |||
| 67 | $this->config->setDefaults(ScaffolderConfig::CONFIG, [ |
||
| 68 | /* |
||
| 69 | * This is set of comment lines to be applied to every scaffolded file, you can use env() function |
||
| 70 | * to make it developer specific or set one universal pattern per project. |
||
| 71 | */ |
||
| 72 | 'header' => [ |
||
| 73 | '{project-name}', |
||
| 74 | '', |
||
| 75 | '@author {author-name}', |
||
| 76 | ], |
||
| 77 | |||
| 78 | /* |
||
| 79 | * Base directory for generated classes, class will be automatically localed into sub directory |
||
| 80 | * using given namespace. |
||
| 81 | */ |
||
| 82 | 'directory' => directory('app') . 'src/', |
||
| 83 | |||
| 84 | /* |
||
| 85 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |
||
| 86 | * |
||
| 87 | * Example: 'namespace' => 'MyApplication' |
||
| 88 | * Controllers: MyApplication\Controllers\SampleController |
||
| 89 | */ |
||
| 90 | 'namespace' => $defaultNamespace, |
||
| 91 | |||
| 92 | /* |
||
| 93 | * This is set of default settings to be used for your scaffolding commands. |
||
| 94 | */ |
||
| 95 | 'declarations' => [ |
||
| 96 | 'bootloader' => [ |
||
| 97 | 'namespace' => 'Bootloader', |
||
| 98 | 'postfix' => 'Bootloader', |
||
| 99 | 'class' => Declaration\BootloaderDeclaration::class, |
||
| 100 | ], |
||
| 101 | 'config' => [ |
||
| 102 | 'namespace' => 'Config', |
||
| 103 | 'postfix' => 'Config', |
||
| 104 | 'class' => Declaration\ConfigDeclaration::class, |
||
| 105 | 'options' => [ |
||
| 106 | 'directory' => directory('config'), |
||
| 107 | ], |
||
| 108 | ], |
||
| 109 | 'controller' => [ |
||
| 110 | 'namespace' => 'Controller', |
||
| 111 | 'postfix' => 'Controller', |
||
| 112 | 'class' => Declaration\ControllerDeclaration::class, |
||
| 113 | ], |
||
| 114 | 'middleware' => [ |
||
| 115 | 'namespace' => 'Middleware', |
||
| 116 | 'postfix' => '', |
||
| 117 | 'class' => Declaration\MiddlewareDeclaration::class, |
||
| 118 | ], |
||
| 119 | 'command' => [ |
||
| 120 | 'namespace' => 'Command', |
||
| 121 | 'postfix' => 'Command', |
||
| 122 | 'class' => Declaration\CommandDeclaration::class, |
||
| 123 | ], |
||
| 124 | 'jobHandler' => [ |
||
| 125 | 'namespace' => 'Job', |
||
| 126 | 'postfix' => 'Job', |
||
| 127 | 'class' => Declaration\JobHandlerDeclaration::class, |
||
| 128 | ], |
||
| 129 | 'migration' => [ |
||
| 130 | 'namespace' => '', |
||
| 131 | 'postfix' => 'Migration', |
||
| 132 | 'class' => Declaration\MigrationDeclaration::class, |
||
| 133 | ], |
||
| 134 | 'filter' => [ |
||
| 135 | 'namespace' => 'Request', |
||
| 136 | 'postfix' => 'Request', |
||
| 137 | 'class' => Declaration\FilterDeclaration::class, |
||
| 138 | 'options' => [ |
||
| 139 | //Set of default filters and validate rules for various types |
||
| 140 | 'mapping' => [ |
||
| 141 | 'int' => [ |
||
| 142 | 'source' => 'data', |
||
| 143 | 'setter' => 'intval', |
||
| 144 | 'validates' => ['notEmpty', 'integer'], |
||
| 145 | ], |
||
| 146 | 'integer' => [ |
||
| 147 | 'source' => 'data', |
||
| 148 | 'setter' => 'intval', |
||
| 149 | 'validates' => ['notEmpty', 'integer'], |
||
| 150 | ], |
||
| 151 | 'float' => [ |
||
| 152 | 'source' => 'data', |
||
| 153 | 'setter' => 'floatval', |
||
| 154 | 'validates' => ['notEmpty', 'float'], |
||
| 155 | ], |
||
| 156 | 'double' => [ |
||
| 157 | 'source' => 'data', |
||
| 158 | 'setter' => 'floatval', |
||
| 159 | 'validates' => ['notEmpty', 'float'], |
||
| 160 | ], |
||
| 161 | 'string' => [ |
||
| 162 | 'source' => 'data', |
||
| 163 | 'setter' => 'strval', |
||
| 164 | 'validates' => ['notEmpty', 'string'], |
||
| 165 | ], |
||
| 166 | 'bool' => [ |
||
| 167 | 'source' => 'data', |
||
| 168 | 'setter' => 'boolval', |
||
| 169 | 'validates' => ['notEmpty', 'boolean'], |
||
| 170 | ], |
||
| 171 | 'boolean' => [ |
||
| 172 | 'source' => 'data', |
||
| 173 | 'setter' => 'boolval', |
||
| 174 | 'validates' => ['notEmpty', 'boolean'], |
||
| 175 | ], |
||
| 176 | 'email' => [ |
||
| 177 | 'source' => 'data', |
||
| 178 | 'setter' => 'strval', |
||
| 179 | 'validates' => ['notEmpty', 'string', 'email'], |
||
| 180 | ], |
||
| 181 | 'file' => [ |
||
| 182 | 'source' => 'file', |
||
| 183 | 'validates' => ['file::uploaded'], |
||
| 184 | ], |
||
| 185 | 'image' => [ |
||
| 186 | 'source' => 'file', |
||
| 187 | 'validates' => ['image::uploaded', 'image::valid'], |
||
| 188 | ], |
||
| 189 | null => [ |
||
| 190 | 'source' => 'data', |
||
| 191 | 'setter' => 'strval', |
||
| 192 | 'validates' => ['notEmpty', 'string'], |
||
| 193 | ], |
||
| 194 | ], |
||
| 195 | ], |
||
| 196 | ], |
||
| 197 | 'entity' => [ |
||
| 198 | 'namespace' => 'Database', |
||
| 199 | 'postfix' => '', |
||
| 200 | 'options' => [ |
||
| 201 | 'annotated' => Declaration\Database\Entity\AnnotatedDeclaration::class, |
||
| 202 | ], |
||
| 203 | ], |
||
| 204 | 'repository' => [ |
||
| 205 | 'namespace' => 'Repository', |
||
| 206 | 'postfix' => 'Repository', |
||
| 207 | 'class' => Declaration\Database\RepositoryDeclaration::class, |
||
| 208 | ], |
||
| 221 |