Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
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 |
||
29 | public function setUp() : void |
||
30 | { |
||
31 | parent::setUp(); |
||
32 | $optionArray = $this->getOptionArray(); |
||
33 | $installer = $this->installerFactory(); |
||
34 | $installer->init(); |
||
35 | $installer->rawCreate(); |
||
36 | $installer->insertSettings($optionArray); |
||
37 | $categoryOne = Db::forTablePrefix('categories')->create(); |
||
38 | $categoryOne |
||
39 | ->set( |
||
40 | [ |
||
41 | 'title' => 'Category One', |
||
42 | 'alias' => 'category-one', |
||
43 | 'rank' => 1, |
||
44 | 'status' => 1 |
||
45 | ]) |
||
46 | ->save(); |
||
47 | $categoryTwo = Db::forTablePrefix('categories')->create(); |
||
48 | $categoryTwo |
||
49 | ->set( |
||
50 | [ |
||
51 | 'title' => 'Category Two', |
||
52 | 'alias' => 'category-two', |
||
53 | 'rank' => 2, |
||
54 | 'status' => 1 |
||
55 | ]) |
||
56 | ->save(); |
||
57 | Db::forTablePrefix('articles') |
||
58 | ->create() |
||
59 | ->set( |
||
60 | [ |
||
61 | 'title' => 'Article One', |
||
62 | 'alias' => 'article-one', |
||
63 | 'category' => $categoryOne->id, |
||
64 | 'rank' => 1, |
||
65 | 'status' => 1 |
||
66 | ]) |
||
67 | ->save(); |
||
68 | Db::forTablePrefix('articles') |
||
69 | ->create() |
||
70 | ->set( |
||
71 | [ |
||
72 | 'title' => 'Article Two', |
||
73 | 'alias' => 'article-two', |
||
74 | 'category' => $categoryTwo->id, |
||
75 | 'rank' => 2, |
||
76 | 'status' => 1 |
||
77 | ]) |
||
78 | ->save(); |
||
79 | Db::forTablePrefix('articles') |
||
80 | ->create() |
||
81 | ->set( |
||
82 | [ |
||
83 | 'title' => 'Article Three', |
||
84 | 'alias' => 'article-three', |
||
85 | 'rank' => 3, |
||
86 | 'status' => 1 |
||
87 | ]) |
||
88 | ->save(); |
||
89 | } |
||
90 | |||
131 |