| Conditions | 3 |
| Paths | 8 |
| Total Lines | 64 |
| 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 |
||
| 67 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
||
| 68 | /** @var ISchemaWrapper $schema */ |
||
| 69 | $schema = $schemaClosure(); |
||
| 70 | |||
| 71 | try { |
||
| 72 | $circles = $schema->getTable('circle_circles'); |
||
| 73 | $circles->addColumn( |
||
| 74 | 'config', 'integer', [ |
||
| 75 | 'notnull' => false, |
||
| 76 | 'length' => 11, |
||
| 77 | 'unsigned' => true, |
||
| 78 | ] |
||
| 79 | ); |
||
| 80 | $circles->addIndex(['config']); |
||
| 81 | } catch (SchemaException $e) { |
||
| 82 | } |
||
| 83 | |||
| 84 | if (!$schema->hasTable('circle_remotes')) { |
||
| 85 | $table = $schema->createTable('circle_remotes'); |
||
| 86 | $table->addColumn( |
||
| 87 | 'id', 'integer', [ |
||
| 88 | 'autoincrement' => true, |
||
| 89 | 'notnull' => true, |
||
| 90 | 'length' => 4, |
||
| 91 | 'unsigned' => true, |
||
| 92 | ] |
||
| 93 | ); |
||
| 94 | $table->addColumn( |
||
| 95 | 'uid', 'string', [ |
||
| 96 | 'notnull' => false, |
||
| 97 | 'length' => 20, |
||
| 98 | ] |
||
| 99 | ); |
||
| 100 | $table->addColumn( |
||
| 101 | 'instance', 'string', [ |
||
| 102 | 'notnull' => false, |
||
| 103 | 'length' => 127, |
||
| 104 | ] |
||
| 105 | ); |
||
| 106 | $table->addColumn( |
||
| 107 | 'href', 'string', [ |
||
| 108 | 'notnull' => false, |
||
| 109 | 'length' => 254, |
||
| 110 | ] |
||
| 111 | ); |
||
| 112 | $table->addColumn( |
||
| 113 | 'item', 'text', [ |
||
| 114 | 'notnull' => false, |
||
| 115 | ] |
||
| 116 | ); |
||
| 117 | $table->addColumn( |
||
| 118 | 'creation', 'datetime', [ |
||
| 119 | 'notnull' => false, |
||
| 120 | ] |
||
| 121 | ); |
||
| 122 | |||
| 123 | $table->setPrimaryKey(['id']); |
||
| 124 | $table->addUniqueIndex(['instance']); |
||
| 125 | $table->addIndex(['uid']); |
||
| 126 | $table->addIndex(['href']); |
||
| 127 | } |
||
| 128 | |||
| 129 | return $schema; |
||
| 130 | } |
||
| 131 | |||
| 134 |