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