| Conditions | 6 |
| Paths | 60 |
| Total Lines | 87 |
| 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 | if (!$circles->hasColumn('config')) { |
||
| 74 | $circles->addColumn( |
||
| 75 | 'config', 'integer', [ |
||
| 76 | 'notnull' => false, |
||
| 77 | 'length' => 11, |
||
| 78 | 'unsigned' => true, |
||
| 79 | ] |
||
| 80 | ); |
||
| 81 | } |
||
| 82 | if (!$circles->hasColumn('instance')) { |
||
| 83 | $circles->addColumn( |
||
| 84 | 'instance', 'string', [ |
||
| 85 | 'notnull' => true, |
||
| 86 | 'default' => '', |
||
| 87 | 'length' => 255 |
||
| 88 | ] |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | $circles->addIndex(['config']); |
||
| 92 | } catch (SchemaException $e) { |
||
| 93 | } |
||
| 94 | |||
| 95 | if (!$schema->hasTable('circle_remotes')) { |
||
| 96 | $table = $schema->createTable('circle_remotes'); |
||
| 97 | $table->addColumn( |
||
| 98 | 'id', 'integer', [ |
||
| 99 | 'autoincrement' => true, |
||
| 100 | 'notnull' => true, |
||
| 101 | 'length' => 4, |
||
| 102 | 'unsigned' => true, |
||
| 103 | ] |
||
| 104 | ); |
||
| 105 | $table->addColumn( |
||
| 106 | 'uid', 'string', [ |
||
| 107 | 'notnull' => false, |
||
| 108 | 'length' => 20, |
||
| 109 | ] |
||
| 110 | ); |
||
| 111 | $table->addColumn( |
||
| 112 | 'instance', 'string', [ |
||
| 113 | 'notnull' => false, |
||
| 114 | 'length' => 127, |
||
| 115 | ] |
||
| 116 | ); |
||
| 117 | $table->addColumn( |
||
| 118 | 'href', 'string', [ |
||
| 119 | 'notnull' => false, |
||
| 120 | 'length' => 254, |
||
| 121 | ] |
||
| 122 | ); |
||
| 123 | $table->addColumn( |
||
| 124 | 'item', 'text', [ |
||
| 125 | 'notnull' => false, |
||
| 126 | ] |
||
| 127 | ); |
||
| 128 | $table->addColumn( |
||
| 129 | 'creation', 'datetime', [ |
||
| 130 | 'notnull' => false, |
||
| 131 | ] |
||
| 132 | ); |
||
| 133 | |||
| 134 | $table->setPrimaryKey(['id']); |
||
| 135 | $table->addUniqueIndex(['instance']); |
||
| 136 | $table->addIndex(['uid']); |
||
| 137 | $table->addIndex(['href']); |
||
| 138 | } |
||
| 139 | |||
| 140 | if (!$schema->hasTable('circle_memberships')) { |
||
| 141 | // $table = $schema->createTable('circle_memberships'); |
||
| 142 | // $table->addColumn( |
||
| 143 | // 'id', 'string', [ |
||
| 144 | // 'notnull' => false, |
||
| 145 | // 'length' => 15, |
||
| 146 | // ] |
||
| 147 | // ); |
||
| 148 | |||
| 149 | // $table->setIndex(['id']); |
||
| 150 | } |
||
| 151 | |||
| 152 | return $schema; |
||
| 153 | } |
||
| 154 | |||
| 157 |