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