Conditions | 2 |
Paths | 2 |
Total Lines | 64 |
Code Lines | 53 |
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 |
||
13 | public function safeUp() |
||
14 | { |
||
15 | $tableOptions = null; |
||
16 | if ('mysql' === $this->db->driverName) { |
||
17 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; |
||
18 | } |
||
19 | |||
20 | $this->createTable('{{%hit_counter}}', [ |
||
21 | 'id' => $this->primaryKey()->unsigned(), |
||
22 | 'counter_id' => $this->string()->notNull(), |
||
23 | 'cookie_mark'=> $this->char(32)->null(), |
||
24 | 'js_cookei_enabled' => $this->boolean()->notNull()->defaultValue(0), |
||
25 | 'js_java_enabled' => $this->boolean()->notNull()->defaultValue(0), |
||
26 | 'js_timezone_offset' => $this->integer()->null(), |
||
27 | 'js_timezone' => $this->string()->null(), |
||
28 | 'js_connection' => $this->string()->null(), |
||
29 | 'js_current_url' => $this->text()->null(), |
||
30 | 'js_referer_url' => $this->text()->null(), |
||
31 | 'js_screen_width' => $this->integer()->null(), |
||
32 | 'js_screen_height' => $this->integer()->null(), |
||
33 | 'js_color_depth' => $this->integer()->null(), |
||
34 | 'js_browser_language' => $this->string()->null(), |
||
35 | 'js_history_length' => $this->integer()->null(), |
||
36 | 'js_is_toutch_device' => $this->boolean()->notNull()->defaultValue(0), |
||
37 | 'js_processor_ram' => $this->integer()->null(), |
||
38 | |||
39 | 'serv_ip' => $this->char(20)->null(), |
||
40 | 'serv_user_agent' => $this->text()->null(), |
||
41 | 'serv_referer_url' => $this->text()->null(), |
||
42 | 'serv_server_name' => $this->string()->null(), |
||
43 | 'serv_auth_user_id' => $this->integer()->unsigned()->null(), |
||
44 | 'serv_port' => $this->integer()->unsigned()->null(), |
||
45 | 'serv_cookies' => 'JSON', |
||
46 | |||
47 | 'serv_os' => $this->string()->null(), |
||
48 | 'serv_client' => $this->string()->null(), |
||
49 | 'serv_device' => $this->string()->null(), |
||
50 | 'serv_brand' => $this->string()->null(), |
||
51 | 'serv_model' => $this->string()->null(), |
||
52 | 'serv_bot' => $this->string()->null(), |
||
53 | 'serv_host_by_ip' => $this->string()->null(), |
||
54 | 'serv_is_proxy_or_vpn' => $this->boolean()->notNull()->defaultValue(0), |
||
55 | |||
56 | 'created_at' => $this->dateTime()->notNull(), |
||
57 | ], $tableOptions); |
||
58 | |||
59 | $this->createIndex('{{%idx-hit_counter-cookie_mark}}', '{{%hit_counter}}', 'cookie_mark'); |
||
60 | $this->createIndex('{{%idx-hit_counter-serv_ip}}', '{{%hit_counter}}', 'serv_ip'); |
||
61 | $this->createIndex('{{%idx-hit_counter-serv_auth_user_id}}', '{{%hit_counter}}', 'serv_auth_user_id'); |
||
62 | $this->createIndex('{{%idx-hit_counter-created_at}}', '{{%hit_counter}}', 'created_at'); |
||
63 | |||
64 | $this->addForeignKey( |
||
65 | '{{%fk-hit_counter-serv_auth_user_id}}', |
||
66 | '{{%hit_counter}}', |
||
67 | 'serv_auth_user_id', |
||
68 | '{{%user}}', |
||
69 | 'id', |
||
70 | 'RESTRICT', |
||
71 | 'CASCADE' |
||
72 | ); |
||
73 | |||
74 | $this->addCommentOnColumn('{{%hit_counter}}', 'serv_auth_user_id', 'User id if exists'); |
||
75 | $this->addCommentOnColumn('{{%hit_counter}}', 'serv_ip', 'User ip'); |
||
76 | $this->addCommentOnColumn('{{%hit_counter}}', 'counter_id', 'Counter id generated in widget and passed by query param in inage src'); |
||
77 | } |
||
106 |