Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 51 |
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 |
||
9 | public function _before(ApiTester $I) |
||
10 | { |
||
11 | $I->haveInRepository(User::class, [ |
||
12 | 'id' => 1, |
||
13 | 'first' => 'Tester', |
||
14 | 'last' => 'Tester', |
||
15 | 'email' => '[email protected]', |
||
16 | ]); |
||
17 | |||
18 | $user = $I->grabEntityFromRepository(User::class, ['id' => 1]); |
||
19 | $I->haveInRepository(DbConfiguration::class, [ |
||
20 | 'owner' => $user, |
||
21 | 'title' => 'sqlite config', |
||
22 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
23 | ]); |
||
24 | $I->haveInRepository(DbConfiguration::class, [ |
||
25 | 'owner' => $user, |
||
26 | 'title' => 'mysql config', |
||
27 | 'url' => 'mysql://test-user:test-pwd@mysql/test', |
||
28 | ]); |
||
29 | $I->haveInRepository(DbConfiguration::class, [ |
||
30 | 'owner' => $user, |
||
31 | 'title' => 'project 1 config', |
||
32 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
33 | ]); |
||
34 | $I->haveInRepository(DbConfiguration::class, [ |
||
35 | 'owner' => $user, |
||
36 | 'title' => 'project 2 config', |
||
37 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
38 | ]); |
||
39 | $I->haveInRepository(DbConfiguration::class, [ |
||
40 | 'owner' => $user, |
||
41 | 'title' => 'project 3 config', |
||
42 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
43 | ]); |
||
44 | $I->haveInRepository(DbConfiguration::class, [ |
||
45 | 'owner' => $user, |
||
46 | 'title' => 'project 4 config', |
||
47 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
48 | ]); |
||
49 | $I->haveInRepository(DbConfiguration::class, [ |
||
50 | 'owner' => $user, |
||
51 | 'title' => 'project 5 config', |
||
52 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
53 | ]); |
||
54 | $I->haveInRepository(DbConfiguration::class, [ |
||
55 | 'owner' => $user, |
||
56 | 'title' => 'project 6 config', |
||
57 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
58 | ]); |
||
59 | $I->haveInRepository(DbConfiguration::class, [ |
||
60 | 'owner' => $user, |
||
61 | 'title' => 'project 7 config', |
||
62 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
63 | ]); |
||
64 | $I->haveInRepository(DbConfiguration::class, [ |
||
65 | 'owner' => $user, |
||
66 | 'title' => 'project 8 config', |
||
67 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
68 | ]); |
||
69 | $I->haveInRepository(DbConfiguration::class, [ |
||
70 | 'owner' => $user, |
||
71 | 'title' => 'project 9 config', |
||
72 | 'url' => 'sqlite:///data/db/db.sqlite', |
||
73 | ]); |
||
74 | } |
||
75 | |||
197 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.