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