| Conditions | 1 |
| Paths | 1 |
| Total Lines | 124 |
| Code Lines | 97 |
| 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 |
||
| 43 | public function up() |
||
| 44 | { |
||
| 45 | /** @var \Migrations\Table $table */ |
||
| 46 | $this->table('groups') |
||
| 47 | ->addColumn('id', 'integer', [ |
||
| 48 | 'limit' => 11, |
||
| 49 | 'autoIncrement' => true, |
||
| 50 | 'default' => null, |
||
| 51 | 'null' => false, |
||
| 52 | 'signed' => false |
||
| 53 | ]) |
||
| 54 | ->addPrimaryKey([ |
||
| 55 | 'id' |
||
| 56 | ]) |
||
| 57 | ->addColumn('parent_id', 'integer', [ |
||
| 58 | 'limit' => 10, |
||
| 59 | 'default' => null, |
||
| 60 | 'null' => true |
||
| 61 | ]) |
||
| 62 | ->addColumn('name', 'string', [ |
||
| 63 | 'limit' => 100, |
||
| 64 | 'default' => null, |
||
| 65 | 'null' => false |
||
| 66 | ]) |
||
| 67 | ->addColumn('slug', 'string', [ |
||
| 68 | 'limit' => 100, |
||
| 69 | 'default' => null, |
||
| 70 | 'null' => false |
||
| 71 | ]) |
||
| 72 | ->addColumn('params', 'text', [ |
||
| 73 | 'default' => null, |
||
| 74 | 'limit' => null, |
||
| 75 | 'null' => true |
||
| 76 | ]) |
||
| 77 | ->addColumn('lft', 'integer', [ |
||
| 78 | 'limit' => 10, |
||
| 79 | 'default' => null, |
||
| 80 | 'null' => true |
||
| 81 | ]) |
||
| 82 | ->addColumn('rght', 'integer', [ |
||
| 83 | 'limit' => 10, |
||
| 84 | 'default' => null, |
||
| 85 | 'null' => true |
||
| 86 | ]) |
||
| 87 | ->create(); |
||
| 88 | |||
| 89 | $this->table('users') |
||
| 90 | ->addColumn('id', 'integer', [ |
||
| 91 | 'limit' => 11, |
||
| 92 | 'autoIncrement' => true, |
||
| 93 | 'default' => null, |
||
| 94 | 'null' => false, |
||
| 95 | 'signed' => false |
||
| 96 | ]) |
||
| 97 | ->addPrimaryKey([ |
||
| 98 | 'id' |
||
| 99 | ]) |
||
| 100 | ->addColumn('group_id', 'integer', [ |
||
| 101 | 'limit' => 10, |
||
| 102 | 'default' => null, |
||
| 103 | 'null' => false |
||
| 104 | ]) |
||
| 105 | ->addColumn('login', 'string', [ |
||
| 106 | 'limit' => 60, |
||
| 107 | 'default' => null, |
||
| 108 | 'null' => false |
||
| 109 | ]) |
||
| 110 | ->addColumn('name', 'string', [ |
||
| 111 | 'limit' => 60, |
||
| 112 | 'default' => null, |
||
| 113 | 'null' => false |
||
| 114 | ]) |
||
| 115 | ->addColumn('slug', 'string', [ |
||
| 116 | 'limit' => 60, |
||
| 117 | 'default' => null, |
||
| 118 | 'null' => false |
||
| 119 | ]) |
||
| 120 | ->addColumn('email', 'string', [ |
||
| 121 | 'limit' => 50, |
||
| 122 | 'default' => null, |
||
| 123 | 'null' => false |
||
| 124 | ]) |
||
| 125 | ->addColumn('password', 'string', [ |
||
| 126 | 'limit' => 100, |
||
| 127 | 'default' => null, |
||
| 128 | 'null' => true |
||
| 129 | ]) |
||
| 130 | ->addColumn('token', 'string', [ |
||
| 131 | 'limit' => 60, |
||
| 132 | 'default' => null, |
||
| 133 | 'null' => true, |
||
| 134 | ]) |
||
| 135 | ->addColumn('status', 'boolean', [ |
||
| 136 | 'limit' => null, |
||
| 137 | 'default' => false, |
||
| 138 | 'null' => false |
||
| 139 | ]) |
||
| 140 | ->addColumn('params', 'text', [ |
||
| 141 | 'default' => null, |
||
| 142 | 'limit' => null, |
||
| 143 | 'null' => true |
||
| 144 | ]) |
||
| 145 | ->addColumn('last_login', 'datetime', [ |
||
| 146 | 'limit' => null, |
||
| 147 | 'null' => true, |
||
| 148 | 'default' => 'CURRENT_TIMESTAMP' |
||
| 149 | ]) |
||
| 150 | ->addColumn('last_action', 'datetime', [ |
||
| 151 | 'limit' => null, |
||
| 152 | 'null' => true, |
||
| 153 | 'default' => 'CURRENT_TIMESTAMP' |
||
| 154 | ]) |
||
| 155 | ->addColumn('modified', 'datetime', [ |
||
| 156 | 'limit' => null, |
||
| 157 | 'null' => true, |
||
| 158 | 'default' => 'CURRENT_TIMESTAMP' |
||
| 159 | ]) |
||
| 160 | ->addColumn('created', 'datetime', [ |
||
| 161 | 'limit' => null, |
||
| 162 | 'null' => true, |
||
| 163 | 'default' => 'CURRENT_TIMESTAMP' |
||
| 164 | ]) |
||
| 165 | ->create(); |
||
| 166 | } |
||
| 167 | |||
| 179 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.