| Conditions | 1 |
| Paths | 1 |
| Total Lines | 69 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| 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 |
||
| 22 | public function safeUp() |
||
| 23 | { |
||
| 24 | $this->createTable(Domain::tableName(), [ |
||
| 25 | 'fieldId' => $this->integer()->notNull(), |
||
| 26 | 'elementId' => $this->integer()->notNull(), |
||
| 27 | 'domain' => $this->string()->notNull(), |
||
| 28 | 'status' => $this->enum('status', ['enabled', 'pending', 'disabled'])->notNull()->defaultValue('enabled'), |
||
| 29 | 'sortOrder' => $this->smallInteger()->unsigned(), |
||
| 30 | 'siteId' => $this->integer()->notNull(), |
||
| 31 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 32 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 33 | 'uid' => $this->uid(), |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $this->addPrimaryKey( |
||
| 37 | null, |
||
| 38 | Domain::tableName(), |
||
| 39 | [ |
||
| 40 | 'fieldId', |
||
| 41 | 'elementId', |
||
| 42 | 'domain', |
||
| 43 | 'siteId' |
||
| 44 | ] |
||
| 45 | ); |
||
| 46 | |||
| 47 | $this->createIndex( |
||
| 48 | null, |
||
| 49 | Domain::tableName(), |
||
| 50 | 'domain', |
||
| 51 | false |
||
| 52 | ); |
||
| 53 | |||
| 54 | $this->createIndex( |
||
| 55 | null, |
||
| 56 | Domain::tableName(), |
||
| 57 | 'status', |
||
| 58 | false |
||
| 59 | ); |
||
| 60 | |||
| 61 | $this->addForeignKey( |
||
| 62 | null, |
||
| 63 | Domain::tableName(), |
||
| 64 | 'fieldId', |
||
| 65 | Field::tableName(), |
||
| 66 | 'id', |
||
| 67 | 'CASCADE', |
||
| 68 | null |
||
| 69 | ); |
||
| 70 | |||
| 71 | $this->addForeignKey( |
||
| 72 | null, |
||
| 73 | Domain::tableName(), |
||
| 74 | 'elementId', |
||
| 75 | Element::tableName(), |
||
| 76 | 'id', |
||
| 77 | 'CASCADE', |
||
| 78 | null |
||
| 79 | ); |
||
| 80 | |||
| 81 | $this->addForeignKey( |
||
| 82 | null, |
||
| 83 | Domain::tableName(), |
||
| 84 | 'siteId', |
||
| 85 | Site::tableName(), |
||
| 86 | 'id', |
||
| 87 | 'CASCADE', |
||
| 88 | 'CASCADE' |
||
| 89 | ); |
||
| 90 | } |
||
| 91 | |||
| 100 |