| Conditions | 4 |
| Paths | 8 |
| Total Lines | 76 |
| Code Lines | 55 |
| 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 |
||
| 70 | protected function createTables(): bool |
||
| 71 | { |
||
| 72 | $tablesCreated = false; |
||
| 73 | |||
| 74 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_redirects}}'); |
||
| 75 | if ($tableSchema === null) { |
||
| 76 | $tablesCreated = true; |
||
| 77 | $this->createTable( |
||
| 78 | '{{%retour_redirects}}', |
||
| 79 | [ |
||
| 80 | 'id' => $this->primaryKey(), |
||
| 81 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 82 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 83 | 'uid' => $this->uid(), |
||
| 84 | |||
| 85 | 'locale' => $this->string(12)->defaultValue('en-US'), |
||
| 86 | 'associatedElementId' => $this->integer()->notNull(), |
||
| 87 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 88 | 'redirectSrcUrlParsed' => $this->string(255)->defaultValue(''), |
||
| 89 | 'redirectSrcMatch' => $this->string(32)->defaultValue('pathonly'), |
||
| 90 | 'redirectMatchType' => $this->string(32)->defaultValue('exactmatch'), |
||
| 91 | 'redirectDestUrl' => $this->string(255)->defaultValue(''), |
||
| 92 | 'redirectHttpCode' => $this->integer()->defaultValue(301), |
||
| 93 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 94 | 'hitLastTime' => $this->dateTime(), |
||
| 95 | ] |
||
| 96 | ); |
||
| 97 | } |
||
| 98 | |||
| 99 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_static_redirects}}'); |
||
| 100 | if ($tableSchema === null) { |
||
| 101 | $tablesCreated = true; |
||
| 102 | $this->createTable( |
||
| 103 | '{{%retour_static_redirects}}', |
||
| 104 | [ |
||
| 105 | 'id' => $this->primaryKey(), |
||
| 106 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 107 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 108 | 'uid' => $this->uid(), |
||
| 109 | |||
| 110 | 'locale' => $this->string(12)->defaultValue('en-US'), |
||
| 111 | 'associatedElementId' => $this->integer()->notNull(), |
||
| 112 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 113 | 'redirectSrcUrlParsed' => $this->string(255)->defaultValue(''), |
||
| 114 | 'redirectSrcMatch' => $this->string(32)->defaultValue('pathonly'), |
||
| 115 | 'redirectMatchType' => $this->string(32)->defaultValue('exactmatch'), |
||
| 116 | 'redirectDestUrl' => $this->string(255)->defaultValue(''), |
||
| 117 | 'redirectHttpCode' => $this->integer()->defaultValue(301), |
||
| 118 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 119 | 'hitLastTime' => $this->dateTime(), |
||
| 120 | ] |
||
| 121 | ); |
||
| 122 | } |
||
| 123 | |||
| 124 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_stats}}'); |
||
| 125 | if ($tableSchema === null) { |
||
| 126 | $tablesCreated = true; |
||
| 127 | $this->createTable( |
||
| 128 | '{{%retour_stats}}', |
||
| 129 | [ |
||
| 130 | 'id' => $this->primaryKey(), |
||
| 131 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 132 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 133 | 'uid' => $this->uid(), |
||
| 134 | |||
| 135 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 136 | 'referrerUrl' => $this->string(2000)->defaultValue(''), |
||
| 137 | 'remoteIp' => $this->string(45)->defaultValue(''), |
||
| 138 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 139 | 'hitLastTime' => $this->dateTime(), |
||
| 140 | 'handledByRetour' => $this->boolean()->defaultValue(false), |
||
| 141 | ] |
||
| 142 | ); |
||
| 143 | } |
||
| 144 | |||
| 145 | return $tablesCreated; |
||
| 146 | } |
||
| 230 |