Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | 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 |
||
22 | public function safeUp() |
||
23 | { |
||
24 | $this->createTable($this->env->pushTableName, [ |
||
25 | 'id' => $this->bigPrimaryKey(), |
||
26 | 'parent_id' => $this->bigInteger(), |
||
27 | 'sender_name' => $this->string(32)->notNull(), |
||
28 | 'job_uid' => $this->string(32)->notNull(), |
||
29 | 'job_class' => $this->string()->notNull(), |
||
30 | 'job_data' => $this->binary()->notNull(), |
||
31 | 'ttr' => $this->integer()->unsigned()->notNull(), |
||
32 | 'delay' => $this->integer()->unsigned()->notNull(), |
||
33 | 'trace' => $this->text(), |
||
34 | 'context' => $this->text(), |
||
35 | 'pushed_at' => $this->integer()->unsigned()->notNull(), |
||
36 | 'stopped_at' => $this->integer()->unsigned(), |
||
37 | 'first_exec_id' => $this->bigInteger(), |
||
38 | 'last_exec_id' => $this->bigInteger(), |
||
39 | ]); |
||
40 | $this->createIndex('ind_qp_parent_id', $this->env->pushTableName, 'parent_id'); |
||
41 | $this->createIndex('ind_qp_job_uid', $this->env->pushTableName, ['sender_name', 'job_uid']); |
||
42 | $this->createIndex('ind_qp_job_class', $this->env->pushTableName, 'job_class'); |
||
43 | $this->createIndex('ind_qp_first_exec_id', $this->env->pushTableName, 'first_exec_id'); |
||
44 | $this->createIndex('ind_qp_last_exec_id', $this->env->pushTableName, 'last_exec_id'); |
||
45 | |||
46 | $this->createTable($this->env->execTableName, [ |
||
47 | 'id' => $this->bigPrimaryKey(), |
||
48 | 'push_id' => $this->bigInteger()->notNull(), |
||
49 | 'worker_id' => $this->bigInteger(), |
||
50 | 'attempt' => $this->integer()->unsigned()->notNull(), |
||
51 | 'started_at' => $this->integer()->unsigned()->notNull(), |
||
52 | 'finished_at' => $this->integer()->unsigned(), |
||
53 | 'memory_usage' => $this->bigInteger()->unsigned(), |
||
54 | 'error' => $this->text(), |
||
55 | 'retry' => $this->boolean(), |
||
56 | ]); |
||
57 | $this->createIndex('ind_qe_push_id', $this->env->execTableName, 'push_id'); |
||
58 | $this->createIndex('ind_qe_worker_id', $this->env->execTableName, 'worker_id'); |
||
59 | |||
60 | $this->createTable($this->env->workerTableName, [ |
||
61 | 'id' => $this->bigPrimaryKey(), |
||
62 | 'sender_name' => $this->string(32)->notNull(), |
||
63 | 'host' => $this->string(64), |
||
64 | 'pid' => $this->integer()->unsigned(), |
||
65 | 'started_at' => $this->integer()->unsigned()->notNull(), |
||
66 | 'pinged_at' => $this->integer()->unsigned()->notNull(), |
||
67 | 'stopped_at' => $this->integer()->unsigned(), |
||
68 | 'finished_at' => $this->integer()->unsigned(), |
||
69 | 'last_exec_id' => $this->bigInteger(), |
||
70 | ]); |
||
71 | $this->createIndex('ind_qw_finished_at', $this->env->workerTableName, 'finished_at'); |
||
72 | $this->createIndex('ind_qw_last_exec_id', $this->env->workerTableName, 'last_exec_id'); |
||
73 | } |
||
85 |