| Conditions | 4 |
| Paths | 8 |
| Total Lines | 85 |
| Code Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 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 |
||
| 75 | protected function createTables(): bool |
||
| 76 | { |
||
| 77 | $tablesCreated = false; |
||
| 78 | |||
| 79 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_redirects}}'); |
||
| 80 | if ($tableSchema === null) { |
||
| 81 | $tablesCreated = true; |
||
| 82 | $this->createTable( |
||
| 83 | '{{%retour_redirects}}', |
||
| 84 | [ |
||
| 85 | 'id' => $this->primaryKey(), |
||
| 86 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 87 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 88 | 'uid' => $this->uid(), |
||
| 89 | |||
| 90 | 'siteId' => $this->integer()->null()->defaultValue(null), |
||
| 91 | 'associatedElementId' => $this->integer()->notNull(), |
||
| 92 | 'enabled' => $this->boolean()->defaultValue(true), |
||
| 93 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 94 | 'redirectSrcUrlParsed' => $this->string(255)->defaultValue(''), |
||
| 95 | 'redirectSrcMatch' => $this->string(32)->defaultValue('pathonly'), |
||
| 96 | 'redirectMatchType' => $this->string(32)->defaultValue('exactmatch'), |
||
| 97 | 'redirectDestUrl' => $this->string(255)->defaultValue(''), |
||
| 98 | 'redirectHttpCode' => $this->integer()->defaultValue(301), |
||
| 99 | 'priority' => $this->integer()->null()->defaultValue(5), |
||
| 100 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 101 | 'hitLastTime' => $this->dateTime(), |
||
| 102 | ] |
||
| 103 | ); |
||
| 104 | } |
||
| 105 | |||
| 106 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_static_redirects}}'); |
||
| 107 | if ($tableSchema === null) { |
||
| 108 | $tablesCreated = true; |
||
| 109 | $this->createTable( |
||
| 110 | '{{%retour_static_redirects}}', |
||
| 111 | [ |
||
| 112 | 'id' => $this->primaryKey(), |
||
| 113 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 114 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 115 | 'uid' => $this->uid(), |
||
| 116 | |||
| 117 | 'siteId' => $this->integer()->null()->defaultValue(null), |
||
| 118 | 'associatedElementId' => $this->integer()->notNull(), |
||
| 119 | 'enabled' => $this->boolean()->defaultValue(true), |
||
| 120 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 121 | 'redirectSrcUrlParsed' => $this->string(255)->defaultValue(''), |
||
| 122 | 'redirectSrcMatch' => $this->string(32)->defaultValue('pathonly'), |
||
| 123 | 'redirectMatchType' => $this->string(32)->defaultValue('exactmatch'), |
||
| 124 | 'redirectDestUrl' => $this->string(255)->defaultValue(''), |
||
| 125 | 'redirectHttpCode' => $this->integer()->defaultValue(301), |
||
| 126 | 'priority' => $this->integer()->null()->defaultValue(5), |
||
| 127 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 128 | 'hitLastTime' => $this->dateTime(), |
||
| 129 | ] |
||
| 130 | ); |
||
| 131 | } |
||
| 132 | |||
| 133 | $tableSchema = Craft::$app->db->schema->getTableSchema('{{%retour_stats}}'); |
||
| 134 | if ($tableSchema === null) { |
||
| 135 | $tablesCreated = true; |
||
| 136 | $this->createTable( |
||
| 137 | '{{%retour_stats}}', |
||
| 138 | [ |
||
| 139 | 'id' => $this->primaryKey(), |
||
| 140 | 'dateCreated' => $this->dateTime()->notNull(), |
||
| 141 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
| 142 | 'uid' => $this->uid(), |
||
| 143 | |||
| 144 | 'siteId' => $this->integer()->null()->defaultValue(null), |
||
| 145 | 'redirectSrcUrl' => $this->string(255)->defaultValue(''), |
||
| 146 | 'referrerUrl' => $this->string(2000)->defaultValue(''), |
||
| 147 | 'remoteIp' => $this->string(45)->defaultValue(''), |
||
| 148 | 'userAgent' => $this->string(255)->defaultValue(''), |
||
| 149 | 'exceptionMessage' => $this->string(255)->defaultValue(''), |
||
| 150 | 'exceptionFilePath' => $this->string(255)->defaultValue(''), |
||
| 151 | 'exceptionFileLine' => $this->integer()->defaultValue(0), |
||
| 152 | 'hitCount' => $this->integer()->defaultValue(1), |
||
| 153 | 'hitLastTime' => $this->dateTime(), |
||
| 154 | 'handledByRetour' => $this->boolean()->defaultValue(false), |
||
| 155 | ] |
||
| 156 | ); |
||
| 157 | } |
||
| 158 | |||
| 159 | return $tablesCreated; |
||
| 160 | } |
||
| 291 |