| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 45 |
| 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 |
||
| 40 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
||
| 41 | /** @var ISchemaWrapper $schema */ |
||
| 42 | $schema = $schemaClosure(); |
||
| 43 | |||
| 44 | $table = $schema->createTable('login_flow_v2'); |
||
| 45 | $table->addColumn('id', Type::BIGINT, [ |
||
| 46 | 'autoincrement' => true, |
||
| 47 | 'notnull' => true, |
||
| 48 | 'length' => 20, |
||
| 49 | 'unsigned' => true, |
||
| 50 | ]); |
||
| 51 | $table->addColumn('timestamp', Type::BIGINT, [ |
||
| 52 | 'notnull' => true, |
||
| 53 | 'length' => 20, |
||
| 54 | 'unsigned' => true, |
||
| 55 | ]); |
||
| 56 | $table->addColumn('started', Type::SMALLINT, [ |
||
| 57 | 'notnull' => true, |
||
| 58 | 'length' => 1, |
||
| 59 | 'unsigned' => true, |
||
| 60 | 'default' => 0, |
||
| 61 | ]); |
||
| 62 | $table->addColumn('poll_token', Type::STRING, [ |
||
| 63 | 'notnull' => true, |
||
| 64 | 'length' => 255, |
||
| 65 | ]); |
||
| 66 | $table->addColumn('login_token', Type::STRING, [ |
||
| 67 | 'notnull' => true, |
||
| 68 | 'length' => 255, |
||
| 69 | ]); |
||
| 70 | $table->addColumn('public_key', Type::TEXT, [ |
||
| 71 | 'notnull' => true, |
||
| 72 | 'length' => 32768, |
||
| 73 | ]); |
||
| 74 | $table->addColumn('private_key', Type::TEXT, [ |
||
| 75 | 'notnull' => true, |
||
| 76 | 'length' => 32768, |
||
| 77 | ]); |
||
| 78 | $table->addColumn('client_name', Type::STRING, [ |
||
| 79 | 'notnull' => true, |
||
| 80 | 'length' => 255, |
||
| 81 | ]); |
||
| 82 | $table->addColumn('login_name', Type::STRING, [ |
||
| 83 | 'notnull' => false, |
||
| 84 | 'length' => 255, |
||
| 85 | ]); |
||
| 86 | $table->addColumn('server', Type::STRING, [ |
||
| 87 | 'notnull' => false, |
||
| 88 | 'length' => 255, |
||
| 89 | ]); |
||
| 90 | $table->addColumn('app_password', Type::STRING, [ |
||
| 91 | 'notnull' => false, |
||
| 92 | 'length' => 1024, |
||
| 93 | ]); |
||
| 94 | $table->setPrimaryKey(['id']); |
||
| 95 | $table->addUniqueIndex(['poll_token']); |
||
| 96 | $table->addUniqueIndex(['login_token']); |
||
| 97 | $table->addIndex(['timestamp']); |
||
| 98 | |||
| 99 | return $schema; |
||
| 100 | } |
||
| 102 |