| Conditions | 1 |
| Paths | 1 |
| Total Lines | 193 |
| Code Lines | 155 |
| 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 |
||
| 20 | public function successProvider(): array |
||
| 21 | { |
||
| 22 | return [ |
||
| 23 | 'param-unnamed-auto-null' => [ |
||
| 24 | 'foo = ?', |
||
| 25 | [null], |
||
| 26 | Params::ALL_AUTO, |
||
| 27 | 'foo = ?', |
||
| 28 | [[null, PDO::PARAM_NULL]], |
||
| 29 | ], |
||
| 30 | 'param-unnamed-auto-int' => ['foo = ?', [2], Params::ALL_AUTO, 'foo = ?', [[2, PDO::PARAM_INT]]], |
||
| 31 | 'param-unnamed-auto-false' => [ |
||
| 32 | 'foo = ?', |
||
| 33 | [false], |
||
| 34 | Params::ALL_AUTO, |
||
| 35 | 'foo = ?', |
||
| 36 | [[false, PDO::PARAM_BOOL]], |
||
| 37 | ], |
||
| 38 | 'param-unnamed-auto-true' => [ |
||
| 39 | 'foo = ?', |
||
| 40 | [true], |
||
| 41 | Params::ALL_AUTO, |
||
| 42 | 'foo = ?', |
||
| 43 | [[true, PDO::PARAM_BOOL]], |
||
| 44 | ], |
||
| 45 | 'param-unnamed-auto-str' => [ |
||
| 46 | 'foo = ?', |
||
| 47 | ['bar'], |
||
| 48 | Params::ALL_AUTO, |
||
| 49 | 'foo = ?', |
||
| 50 | [['bar', PDO::PARAM_STR]], |
||
| 51 | ], |
||
| 52 | 'param-unnamed-str' => [ |
||
| 53 | 'foo = ?', |
||
| 54 | [2], |
||
| 55 | Params::ALL_STRING, |
||
| 56 | 'foo = ?', |
||
| 57 | [[2, PDO::PARAM_STR]], |
||
| 58 | ], |
||
| 59 | 'param-unnamed-manual' => [ |
||
| 60 | 'foo = ?', |
||
| 61 | [[2, PDO::PARAM_BOOL]], |
||
| 62 | Params::ALL_MANUAL, |
||
| 63 | 'foo = ?', |
||
| 64 | [[2, PDO::PARAM_BOOL]], |
||
| 65 | ], |
||
| 66 | 'param-named-auto' => [ |
||
| 67 | 'foo = :foo', |
||
| 68 | ['foo' => 2], |
||
| 69 | Params::ALL_AUTO, |
||
| 70 | 'foo = :foo', |
||
| 71 | ['foo' => [2, PDO::PARAM_INT]], |
||
| 72 | ], |
||
| 73 | 'param-named-str' => [ |
||
| 74 | 'foo = :foo', |
||
| 75 | ['foo' => 2], |
||
| 76 | Params::ALL_STRING, |
||
| 77 | 'foo = :foo', |
||
| 78 | ['foo' => [2, PDO::PARAM_STR]], |
||
| 79 | ], |
||
| 80 | 'param-named-manual' => [ |
||
| 81 | 'foo = :foo', |
||
| 82 | ['foo' => [2, PDO::PARAM_BOOL]], |
||
| 83 | Params::ALL_MANUAL, |
||
| 84 | 'foo = :foo', |
||
| 85 | ['foo' => [2, PDO::PARAM_BOOL]], |
||
| 86 | ], |
||
| 87 | 'unnamed-extend-auto-simple' => [ |
||
| 88 | 'foo IN (?)', |
||
| 89 | [['bar', 'baz']], |
||
| 90 | Params::ALL_AUTO, |
||
| 91 | 'foo IN (?, ?)', |
||
| 92 | [['bar', PDO::PARAM_STR], ['baz', PDO::PARAM_STR]], |
||
| 93 | ], |
||
| 94 | 'unnamed-extend-auto-end' => [ |
||
| 95 | 'foo IN (?', |
||
| 96 | [['bar', 'baz']], |
||
| 97 | Params::ALL_AUTO, |
||
| 98 | 'foo IN (?, ?', |
||
| 99 | [['bar', PDO::PARAM_STR], ['baz', PDO::PARAM_STR]], |
||
| 100 | ], |
||
| 101 | 'unnamed-extend-auto-beginning' => [ |
||
| 102 | '?)', |
||
| 103 | [['bar', 'baz']], |
||
| 104 | Params::ALL_AUTO, |
||
| 105 | '?, ?)', |
||
| 106 | [['bar', PDO::PARAM_STR], ['baz', PDO::PARAM_STR]], |
||
| 107 | ], |
||
| 108 | 'unnamed-extend-auto-complex' => [ |
||
| 109 | 'foo IN (?) AND bar = ? AND baz IN (?)', |
||
| 110 | [['bar', 'baz'], 'quix', [17, 34]], |
||
| 111 | Params::ALL_AUTO, |
||
| 112 | 'foo IN (?, ?) AND bar = ? AND baz IN (?, ?)', |
||
| 113 | [ |
||
| 114 | ['bar', PDO::PARAM_STR], |
||
| 115 | ['baz', PDO::PARAM_STR], |
||
| 116 | ['quix', PDO::PARAM_STR], |
||
| 117 | [17, PDO::PARAM_INT], |
||
| 118 | [34, PDO::PARAM_INT], |
||
| 119 | ], |
||
| 120 | ], |
||
| 121 | 'unnamed-extend-manual-complex' => [ |
||
| 122 | 'foo IN (?) AND bar = ? AND baz IN (?)', |
||
| 123 | [ |
||
| 124 | [['bar', PDO::PARAM_STR], ['baz', PDO::PARAM_STR]], |
||
| 125 | ['quix', PDO::PARAM_STR], |
||
| 126 | [[17, PDO::PARAM_INT], [34, PDO::PARAM_STR]], |
||
| 127 | ], |
||
| 128 | Params::ALL_MANUAL, |
||
| 129 | 'foo IN (?, ?) AND bar = ? AND baz IN (?, ?)', |
||
| 130 | [ |
||
| 131 | ['bar', PDO::PARAM_STR], |
||
| 132 | ['baz', PDO::PARAM_STR], |
||
| 133 | ['quix', PDO::PARAM_STR], |
||
| 134 | [17, PDO::PARAM_INT], |
||
| 135 | [34, PDO::PARAM_STR], |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | 'unnamed-extend-str-complex' => [ |
||
| 139 | 'foo IN (?) AND bar = ? AND baz IN (?)', |
||
| 140 | [['bar', 'baz'], 'quix', [17, 34]], |
||
| 141 | Params::ALL_STRING, |
||
| 142 | 'foo IN (?, ?) AND bar = ? AND baz IN (?, ?)', |
||
| 143 | [ |
||
| 144 | ['bar', PDO::PARAM_STR], |
||
| 145 | ['baz', PDO::PARAM_STR], |
||
| 146 | ['quix', PDO::PARAM_STR], |
||
| 147 | [17, PDO::PARAM_STR], |
||
| 148 | [34, PDO::PARAM_STR], |
||
| 149 | ], |
||
| 150 | ], |
||
| 151 | 'named-extend-auto-simple' => [ |
||
| 152 | 'foo IN (:foo)', |
||
| 153 | ['foo' => ['bar', 'baz']], |
||
| 154 | Params::ALL_AUTO, |
||
| 155 | 'foo IN (:foo_0, :foo_1)', |
||
| 156 | ['foo_0' => ['bar', PDO::PARAM_STR], 'foo_1' => ['baz', PDO::PARAM_STR]], |
||
| 157 | ], |
||
| 158 | 'named-extend-auto-end' => [ |
||
| 159 | 'foo IN (:foo', |
||
| 160 | ['foo' => ['bar', 'baz']], |
||
| 161 | Params::ALL_AUTO, |
||
| 162 | 'foo IN (:foo_0, :foo_1', |
||
| 163 | ['foo_0' => ['bar', PDO::PARAM_STR], 'foo_1' => ['baz', PDO::PARAM_STR]], |
||
| 164 | ], |
||
| 165 | 'named-extend-auto-beginning' => [ |
||
| 166 | ':foo)', |
||
| 167 | ['foo' => ['bar', 'baz']], |
||
| 168 | Params::ALL_AUTO, |
||
| 169 | ':foo_0, :foo_1)', |
||
| 170 | ['foo_0' => ['bar', PDO::PARAM_STR], 'foo_1' => ['baz', PDO::PARAM_STR]], |
||
| 171 | ], |
||
| 172 | 'named-extend-auto-complex' => [ |
||
| 173 | 'foo IN (:foo) AND bar = :bar AND baz IN (:baz)', |
||
| 174 | ['foo' => ['bar', 'baz'], 'bar' => 'quix', 'baz' => [17, 34]], |
||
| 175 | Params::ALL_AUTO, |
||
| 176 | 'foo IN (:foo_0, :foo_1) AND bar = :bar AND baz IN (:baz_0, :baz_1)', |
||
| 177 | [ |
||
| 178 | 'foo_0' => ['bar', PDO::PARAM_STR], |
||
| 179 | 'foo_1' => ['baz', PDO::PARAM_STR], |
||
| 180 | 'bar' => ['quix', PDO::PARAM_STR], |
||
| 181 | 'baz_0' => [17, PDO::PARAM_INT], |
||
| 182 | 'baz_1' => [34, PDO::PARAM_INT], |
||
| 183 | ], |
||
| 184 | ], |
||
| 185 | 'named-extend-manual-complex' => [ |
||
| 186 | 'foo IN (:foo) AND bar = :bar AND baz IN (:baz)', |
||
| 187 | [ |
||
| 188 | 'foo' => [['bar', PDO::PARAM_STR], ['baz', PDO::PARAM_STR]], |
||
| 189 | 'bar' => ['quix', PDO::PARAM_STR], |
||
| 190 | 'baz' => [[17, PDO::PARAM_INT], [34, PDO::PARAM_STR]], |
||
| 191 | ], |
||
| 192 | Params::ALL_MANUAL, |
||
| 193 | 'foo IN (:foo_0, :foo_1) AND bar = :bar AND baz IN (:baz_0, :baz_1)', |
||
| 194 | [ |
||
| 195 | 'foo_0' => ['bar', PDO::PARAM_STR], |
||
| 196 | 'foo_1' => ['baz', PDO::PARAM_STR], |
||
| 197 | 'bar' => ['quix', PDO::PARAM_STR], |
||
| 198 | 'baz_0' => [17, PDO::PARAM_INT], |
||
| 199 | 'baz_1' => [34, PDO::PARAM_STR], |
||
| 200 | ], |
||
| 201 | ], |
||
| 202 | 'named-extend-str-complex' => [ |
||
| 203 | 'foo IN (:foo) AND bar = :bar AND baz IN (:baz)', |
||
| 204 | ['foo' => ['bar', 'baz'], 'bar' => 'quix', 'baz' => [17, 34]], |
||
| 205 | Params::ALL_STRING, |
||
| 206 | 'foo IN (:foo_0, :foo_1) AND bar = :bar AND baz IN (:baz_0, :baz_1)', |
||
| 207 | [ |
||
| 208 | 'foo_0' => ['bar', PDO::PARAM_STR], |
||
| 209 | 'foo_1' => ['baz', PDO::PARAM_STR], |
||
| 210 | 'bar' => ['quix', PDO::PARAM_STR], |
||
| 211 | 'baz_0' => [17, PDO::PARAM_STR], |
||
| 212 | 'baz_1' => [34, PDO::PARAM_STR], |
||
| 213 | ], |
||
| 276 |