| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 59 |
| 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 |
||
| 186 | private function createContent() |
||
| 187 | { |
||
| 188 | $this->createTable('content', array( |
||
| 189 | 'id' => 'integer NOT NULL', |
||
| 190 | 'vid' => 'integer NOT NULL DEFAULT 1', |
||
| 191 | 'title' => 'string NOT NULL', |
||
| 192 | 'content' => 'text NOT NULL', |
||
| 193 | 'excerpt' => 'text NOT NULL', |
||
| 194 | 'slug' => 'string NOT NULL', |
||
| 195 | 'category_id' => 'integer DEFAULT 1', |
||
| 196 | 'author_id' => 'integer DEFAULT 1', |
||
| 197 | 'type_id' => 'integer DEFAULT 2', |
||
| 198 | 'commentable' => 'integer DEFAULT 1', |
||
| 199 | 'password' => 'string DEFAULT NULL', |
||
| 200 | 'status' => 'integer DEFAULT 0', |
||
| 201 | 'like_count' => 'integer DEFAULT 0', |
||
| 202 | 'published' => 'integer', |
||
| 203 | 'created' => 'integer', |
||
| 204 | 'updated' => 'integer' |
||
| 205 | )); |
||
| 206 | |||
| 207 | $this->createTable('content_types', array( |
||
| 208 | 'id' => 'pk', |
||
| 209 | 'name' => 'string NOT NULL', |
||
| 210 | 'created' => 'integer', |
||
| 211 | 'updated' => 'integer' |
||
| 212 | )); |
||
| 213 | |||
| 214 | $this->createTable('content_metadata', array( |
||
| 215 | 'content_id' => 'integer', |
||
| 216 | 'key' => 'string NOT NULL', |
||
| 217 | 'value' => 'text NOT NULL', |
||
| 218 | 'created' => 'integer', |
||
| 219 | 'updated' => 'integer' |
||
| 220 | )); |
||
| 221 | |||
| 222 | $this->createTable('comments', array( |
||
| 223 | 'id' => 'pk', |
||
| 224 | 'content_id' => 'integer', |
||
| 225 | 'author_id' => 'integer', |
||
| 226 | 'comment' => 'integer', |
||
| 227 | 'created' => 'integer', |
||
| 228 | 'updated' => 'integer' |
||
| 229 | )); |
||
| 230 | |||
| 231 | $this->insert('content_types', array( |
||
| 232 | 'id' => 1, |
||
| 233 | 'name' => 'Static Page', |
||
| 234 | 'created' => $this->_moment, |
||
| 235 | 'updated' => $this->_moment |
||
| 236 | )); |
||
| 237 | |||
| 238 | $this->insert('content_types', array( |
||
| 239 | 'id' => 2, |
||
| 240 | 'name' => 'Blog Post', |
||
| 241 | 'created' => $this->_moment, |
||
| 242 | 'updated' => $this->_moment |
||
| 243 | )); |
||
| 244 | |||
| 245 | $this->addPrimaryKey('content_composite', 'content', 'id, vid'); |
||
| 246 | |||
| 247 | $this->execute('ALTER TABLE `content` CHANGE id id INT( 11 ) NOT NULL AUTO_INCREMENT'); |
||
| 248 | |||
| 249 | $this->addPrimaryKey('content_metadata_composite', 'content_metadata', 'content_id,key'); |
||
| 250 | |||
| 251 | $this->createIndex('content_author', 'content', 'author_id', false); |
||
| 252 | $this->createIndex('content_category', 'content', 'category_id', false); |
||
| 253 | $this->createIndex('content_type', 'content', 'type_id', false); |
||
| 254 | $this->createIndex('comment_content', 'comments', 'content_id', false); |
||
| 255 | $this->createIndex('comment_author', 'comments', 'author_id', false); |
||
| 256 | |||
| 257 | $this->addForeignKey('content_category_fk', 'content', 'category_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
||
| 258 | $this->addForeignKey('content_author_fk', 'content', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
||
| 259 | $this->addForeignKey('content_type_fk', 'content', 'type_id', 'content_types', 'id', 'CASCADE', 'NO ACTION'); |
||
| 260 | |||
| 261 | $this->addForeignKey('comments_content_id_fk', 'comments', 'content_id', 'content', 'id', 'CASCADE', 'NO ACTION'); |
||
| 262 | $this->addForeignKey('comments_author_fk', 'comments', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
||
| 263 | } |
||
| 264 | |||
| 288 | } |
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.