Conditions | 1 |
Paths | 1 |
Total Lines | 126 |
Code Lines | 57 |
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 |
||
18 | public function ticketProvider() |
||
19 | { |
||
20 | return [ |
||
21 | [ |
||
22 | 'SELECT * FROM ddc1372_foobar f WHERE f.foo = :foo AND f.bar IN (:bar)', |
||
23 | [ |
||
24 | 'foo' => 1, |
||
25 | 'bar' => [1, 2, 3], |
||
26 | ], |
||
27 | [ |
||
28 | 'foo' => ParameterType::INTEGER, |
||
29 | 'bar' => Connection::PARAM_INT_ARRAY, |
||
30 | ], |
||
31 | [ |
||
32 | ['id' => 1, 'foo' => 1, 'bar' => 1], |
||
33 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
34 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
35 | ], |
||
36 | ], |
||
37 | |||
38 | [ |
||
39 | 'SELECT * FROM ddc1372_foobar f WHERE f.foo = :foo AND f.bar IN (:bar)', |
||
40 | [ |
||
41 | 'foo' => 1, |
||
42 | 'bar' => [1, 2, 3], |
||
43 | ], |
||
44 | [ |
||
45 | 'bar' => Connection::PARAM_INT_ARRAY, |
||
46 | 'foo' => ParameterType::INTEGER, |
||
47 | ], |
||
48 | [ |
||
49 | ['id' => 1, 'foo' => 1, 'bar' => 1], |
||
50 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
51 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
52 | ], |
||
53 | ], |
||
54 | |||
55 | [ |
||
56 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', |
||
57 | [ |
||
58 | 'foo' => 1, |
||
59 | 'bar' => [1, 2, 3], |
||
60 | ], |
||
61 | [ |
||
62 | 'bar' => Connection::PARAM_INT_ARRAY, |
||
63 | 'foo' => ParameterType::INTEGER, |
||
64 | ], |
||
65 | [ |
||
66 | ['id' => 1, 'foo' => 1, 'bar' => 1], |
||
67 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
68 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
69 | ], |
||
70 | ], |
||
71 | |||
72 | [ |
||
73 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', |
||
74 | [ |
||
75 | 'foo' => 1, |
||
76 | 'bar' => ['1', '2', '3'], |
||
77 | ], |
||
78 | [ |
||
79 | 'bar' => Connection::PARAM_STR_ARRAY, |
||
80 | 'foo' => ParameterType::INTEGER, |
||
81 | ], |
||
82 | [ |
||
83 | ['id' => 1, 'foo' => 1, 'bar' => 1], |
||
84 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
85 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
86 | ], |
||
87 | ], |
||
88 | |||
89 | [ |
||
90 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', |
||
91 | [ |
||
92 | 'foo' => ['1'], |
||
93 | 'bar' => [1, 2, 3, 4], |
||
94 | ], |
||
95 | [ |
||
96 | 'bar' => Connection::PARAM_STR_ARRAY, |
||
97 | 'foo' => Connection::PARAM_INT_ARRAY, |
||
98 | ], |
||
99 | [ |
||
100 | ['id' => 1, 'foo' => 1, 'bar' => 1], |
||
101 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
102 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
103 | ['id' => 4, 'foo' => 1, 'bar' => 4], |
||
104 | ], |
||
105 | ], |
||
106 | |||
107 | [ |
||
108 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', |
||
109 | [ |
||
110 | 'foo' => 1, |
||
111 | 'bar' => 2, |
||
112 | ], |
||
113 | [ |
||
114 | 'bar' => ParameterType::INTEGER, |
||
115 | 'foo' => ParameterType::INTEGER, |
||
116 | ], |
||
117 | [ |
||
118 | ['id' => 2, 'foo' => 1, 'bar' => 2], |
||
119 | ], |
||
120 | ], |
||
121 | |||
122 | [ |
||
123 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar = :arg AND f.foo <> :arg', |
||
124 | ['arg' => '1'], |
||
125 | [ |
||
126 | 'arg' => ParameterType::STRING, |
||
127 | ], |
||
128 | [ |
||
129 | ['id' => 5, 'foo' => 2, 'bar' => 1], |
||
130 | ], |
||
131 | ], |
||
132 | |||
133 | [ |
||
134 | 'SELECT * FROM ddc1372_foobar f WHERE f.bar NOT IN (:arg) AND f.foo IN (:arg)', |
||
135 | [ |
||
136 | 'arg' => [1, 2], |
||
137 | ], |
||
138 | [ |
||
139 | 'arg' => Connection::PARAM_INT_ARRAY, |
||
140 | ], |
||
141 | [ |
||
142 | ['id' => 3, 'foo' => 1, 'bar' => 3], |
||
143 | ['id' => 4, 'foo' => 1, 'bar' => 4], |
||
144 | ], |
||
271 |