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