Conditions | 1 |
Paths | 1 |
Total Lines | 75 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
47 | public function dataProvider() |
||
48 | { |
||
49 | $user = 'demo0'; |
||
50 | $password = 'pwd'; |
||
51 | $db = 'test'; |
||
52 | $port = '555'; |
||
53 | $host = 'somehost'; |
||
54 | $path = '/dev/null'; |
||
55 | |||
56 | return [ |
||
57 | [ |
||
58 | PdoMySqlConfiguration::class, |
||
59 | [ |
||
60 | 'host' => $host, |
||
61 | 'port' => $port, |
||
62 | 'DATABASE' => $db, |
||
63 | 'user' => $user, |
||
64 | 'password' => $password, |
||
65 | ], |
||
66 | [ |
||
67 | 'driver' => 'pdo_mysql', |
||
68 | 'user' => $user, |
||
69 | 'host' => $host, |
||
70 | 'password' => $password, |
||
71 | 'port' => (int) $port, |
||
72 | 'dbname' => $db, |
||
73 | ], |
||
74 | ], |
||
75 | [ |
||
76 | PdoPgSqlConfiguration::class, |
||
77 | [ |
||
78 | 'host' => $host, |
||
79 | 'port' => $port, |
||
80 | 'DATABASE' => $db, |
||
81 | 'user' => $user, |
||
82 | 'password' => $password, |
||
83 | ], |
||
84 | [ |
||
85 | 'driver' => 'pdo_pgsql', |
||
86 | 'user' => $user, |
||
87 | 'host' => $host, |
||
88 | 'password' => $password, |
||
89 | 'port' => (int) $port, |
||
90 | 'dbname' => $db, |
||
91 | ], |
||
92 | ], |
||
93 | [ |
||
94 | PdoSqliteDriverConfiguration::class, |
||
95 | [ |
||
96 | 'path' => $path, |
||
97 | 'in_memory' => false, |
||
98 | 'user' => $user, |
||
99 | 'password' => $password, |
||
100 | ], |
||
101 | [ |
||
102 | 'driver' => 'pdo_sqlite', |
||
103 | 'path' => $path, |
||
104 | 'user' => $user, |
||
105 | 'password' => $password, |
||
106 | 'memory' => false, |
||
107 | ], |
||
108 | ], |
||
109 | [ |
||
110 | PdoSqliteDriverConfiguration::class, |
||
111 | [ |
||
112 | 'path' => $path, |
||
113 | 'in_memory' => true, |
||
114 | 'user' => $user, |
||
115 | 'password' => $password, |
||
116 | ], |
||
117 | [ |
||
118 | 'driver' => 'pdo_sqlite', |
||
119 | 'user' => $user, |
||
120 | 'password' => $password, |
||
121 | 'memory' => true, |
||
122 | ], |
||
127 |