| Conditions | 1 |
| Paths | 1 |
| Total Lines | 115 |
| Code Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 66 | public function insertProvider() |
||
| 67 | { |
||
| 68 | |||
| 69 | /** |
||
| 70 | * 1) Just insert |
||
| 71 | * 2) Insert empty index |
||
| 72 | * 3) Insert empty query |
||
| 73 | * 4) Insert with special symbols |
||
| 74 | * 5) Insert with tags as string without filter |
||
| 75 | * 6) Insert with tags as array of string without filter |
||
| 76 | * 7) Insert tags with special symbols |
||
| 77 | * 8) Insert with filter, withowt tags |
||
| 78 | * 9) Insert filter with special symbols |
||
| 79 | * 10) Insert two filters |
||
| 80 | * 11) Insert filter + tags |
||
| 81 | */ |
||
| 82 | |||
| 83 | |||
| 84 | return [ |
||
| 85 | [ |
||
| 86 | 1, |
||
| 87 | 'full text query terms', |
||
| 88 | 'pq', |
||
| 89 | null, |
||
| 90 | null, |
||
| 91 | "INSERT INTO pq (query) VALUES ('full text query terms')" |
||
| 92 | ], |
||
| 93 | |||
| 94 | [ |
||
| 95 | 2, |
||
| 96 | 'full text query terms', |
||
| 97 | null, |
||
| 98 | null, |
||
| 99 | null, |
||
| 100 | null |
||
| 101 | ], |
||
| 102 | |||
| 103 | [ |
||
| 104 | 3, |
||
| 105 | null, |
||
| 106 | 'pq', |
||
| 107 | null, |
||
| 108 | null, |
||
| 109 | null |
||
| 110 | ], |
||
| 111 | |||
| 112 | [ |
||
| 113 | 4, |
||
| 114 | '@doc (text) \' ^ $ " | ! ~ / = >< & - \query terms', |
||
| 115 | 'pq', |
||
| 116 | null, |
||
| 117 | null, |
||
| 118 | 'INSERT INTO pq (query) VALUES (\'@doc (text) \\\\\\\' ^ $ \\\\\\" | \\\\! \\\\~ \\\\/ = >\\\\< & \\\\- \\\\\\\\query terms\')' |
||
| 119 | ], |
||
| 120 | |||
| 121 | [ |
||
| 122 | 5, |
||
| 123 | '@subject match by field', |
||
| 124 | 'pq', |
||
| 125 | 'tag2,tag3', |
||
| 126 | 'price>3', |
||
| 127 | "INSERT INTO pq (query, tags, filters) VALUES ('@subject match by field', 'tag2,tag3', 'price>3')" |
||
| 128 | ], |
||
| 129 | |||
| 130 | [ |
||
| 131 | 6, |
||
| 132 | '@subject orange', |
||
| 133 | 'pq', |
||
| 134 | ['tag2', 'tag3'], |
||
| 135 | null, |
||
| 136 | "INSERT INTO pq (query, tags) VALUES ('@subject orange', 'tag2,tag3')" |
||
| 137 | ], |
||
| 138 | |||
| 139 | [ |
||
| 140 | 7, |
||
| 141 | '@subject orange', |
||
| 142 | 'pq', |
||
| 143 | '@doc (text) \' ^ $ " | ! ~ / = >< & - \query terms', |
||
| 144 | null, |
||
| 145 | 'INSERT INTO pq (query, tags) VALUES (\'@subject orange\', \'@doc (text) \\\\\\\' ^ $ \\\\\" | \\\\! \\\\~ \\\\/ = >\\\\< & \\\\- \\\\\\\\query terms\')' |
||
| 146 | ], |
||
| 147 | |||
| 148 | [ |
||
| 149 | 8, |
||
| 150 | 'catch me', |
||
| 151 | 'pq', |
||
| 152 | null, |
||
| 153 | 'price>3', |
||
| 154 | 'INSERT INTO pq (query, filters) VALUES (\'catch me\', \'price>3\')' |
||
| 155 | ], |
||
| 156 | |||
| 157 | [ |
||
| 158 | 9, |
||
| 159 | 'catch me if can', |
||
| 160 | 'pq', |
||
| 161 | null, |
||
| 162 | 'p\@r\'ice>3', |
||
| 163 | 'INSERT INTO pq (query, filters) VALUES (\'catch me if can\', \'price>3\')' |
||
| 164 | ], |
||
| 165 | |||
| 166 | [ |
||
| 167 | 10, |
||
| 168 | 'catch me if can', |
||
| 169 | 'pq', |
||
| 170 | null, |
||
| 171 | 'price>3, secondFilter>0', |
||
| 172 | null |
||
| 173 | ], |
||
| 174 | [ |
||
| 175 | 11, |
||
| 176 | 'orange|apple|cherry', |
||
| 177 | 'pq', |
||
| 178 | ['tag2', 'tag3'], |
||
| 179 | 'price>3', |
||
| 180 | "INSERT INTO pq (query, tags, filters) VALUES ('orange|apple|cherry', 'tag2,tag3', 'price>3')" |
||
| 181 | ], |
||
| 300 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.