Conditions | 1 |
Paths | 1 |
Total Lines | 167 |
Code Lines | 105 |
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 |
||
93 | public function regex(): array |
||
94 | { |
||
95 | return [ |
||
96 | [ |
||
97 | |||
98 | // Presto based |
||
99 | '/(opera\smini)\/([\w\.-]+)/i', // Opera Mini |
||
100 | '/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i', // Opera Mobi/Tablet |
||
101 | '/(opera).+version\/([\w\.]+)/i', // Opera > 9.80 |
||
102 | '/(opera)[\/\s]+([\w\.]+)/i' // Opera < 9.80 |
||
103 | ], [self::NAME, self::VERSION], [ |
||
104 | |||
105 | '/(opios)[\/\s]+([\w\.]+)/i' // Opera mini on iphone >= 8.0 |
||
106 | ], [[self::NAME, 'Opera Mini'], self::VERSION], [ |
||
107 | |||
108 | '/\s(opr)\/([\w\.]+)/i' // Opera Webkit |
||
109 | ], [[self::NAME, 'Opera'], self::VERSION], [ |
||
110 | |||
111 | // Mixed |
||
112 | '/(kindle)\/([\w\.]+)/i', // Kindle |
||
113 | '/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i', |
||
114 | // Lunascape/Maxthon/Netfront/Jasmine/Blazer |
||
115 | |||
116 | // Trident based |
||
117 | '/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i', |
||
118 | // Avant/IEMobile/SlimBrowser/Baidu |
||
119 | '/(?:ms|\()(ie)\s([\w\.]+)/i', // Internet Explorer |
||
120 | |||
121 | // Webkit/KHTML based |
||
122 | '/(rekonq)\/([\w\.]*)/i', // Rekonq |
||
123 | '/(Instagram)\s([\w\.]+)/i', // Instagram inApp Browser |
||
124 | '/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i' |
||
125 | // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon |
||
126 | ], [self::NAME, self::VERSION], [ |
||
127 | |||
128 | '/(konqueror)\/([\w\.]+)/i' // Konqueror |
||
129 | ], [[self::NAME, 'Konqueror'], self::VERSION], [ |
||
130 | |||
131 | '/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i' // IE11 |
||
132 | ], [[self::NAME, 'IE'], self::VERSION], [ |
||
133 | |||
134 | '/(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i' // Microsoft Edge |
||
135 | ], [[self::NAME, 'Edge'], self::VERSION], [ |
||
136 | |||
137 | '/(yabrowser)\/([\w\.]+)/i' // Yandex |
||
138 | ], [[self::NAME, 'Yandex'], self::VERSION], [ |
||
139 | |||
140 | '/(puffin)\/([\w\.]+)/i' // Puffin |
||
141 | ], [[self::NAME, 'Puffin'], self::VERSION], [ |
||
142 | |||
143 | '/(focus)\/([\w\.]+)/i' // Firefox Focus |
||
144 | ], [[self::NAME, 'Firefox Focus'], self::VERSION], [ |
||
145 | |||
146 | '/(opt)\/([\w\.]+)/i' // Opera Touch |
||
147 | ], [[self::NAME, 'Opera Touch'], self::VERSION], [ |
||
148 | |||
149 | '/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i' // UCBrowser |
||
150 | ], [[self::NAME, 'UCBrowser'], self::VERSION], [ |
||
151 | |||
152 | '/(comodo_dragon)\/([\w\.]+)/i' // Comodo Dragon |
||
153 | ], [[self::NAME, '/_/g', ' '], self::VERSION], [ |
||
154 | |||
155 | '/(windowswechat qbcore)\/([\w\.]+)/i' // WeChat Desktop for Windows Built-in Browser |
||
156 | ], [[self::NAME, 'WeChat(Win) Desktop'], self::VERSION], [ |
||
157 | |||
158 | '/(micromessenger)\/([\w\.]+)/i' // WeChat |
||
159 | ], [[self::NAME, 'WeChat'], self::VERSION], [ |
||
160 | |||
161 | '/(brave)\/([\w\.]+)/i' // Brave browser |
||
162 | ], [[self::NAME, 'Brave'], self::VERSION], [ |
||
163 | |||
164 | '/(qqbrowserlite)\/([\w\.]+)/i' // QQBrowserLite |
||
165 | ], [self::NAME, self::VERSION], [ |
||
166 | |||
167 | '/(QQ)\/([\d\.]+)/i' // QQ, aka ShouQ |
||
168 | ], [self::NAME, self::VERSION], [ |
||
169 | |||
170 | '/m?(qqbrowser)[\/\s]?([\w\.]+)/i' // QQBrowser |
||
171 | ], [self::NAME, self::VERSION], [ |
||
172 | |||
173 | '/(BIDUBrowser)[\/\s]?([\w\.]+)/i' // Baidu Browser |
||
174 | ], [self::NAME, self::VERSION], [ |
||
175 | |||
176 | '/(2345Explorer)[\/\s]?([\w\.]+)/i' // 2345 Browser |
||
177 | ], [self::NAME, self::VERSION], [ |
||
178 | |||
179 | '/(MetaSr)[\/\s]?([\w\.]+)/i' // SouGouBrowser |
||
180 | ], [self::NAME], [ |
||
181 | |||
182 | '/(LBBROWSER)/i' // LieBao Browser |
||
183 | ], [self::NAME], [ |
||
184 | |||
185 | '/xiaomi\/miuibrowser\/([\w\.]+)/i' // MIUI Browser |
||
186 | ], [self::VERSION, [self::NAME, 'MIUI Browser']], [ |
||
187 | |||
188 | '/;(fbav)\/([\w\.]+);/i' // Facebook App for iOS & Android |
||
189 | ], [[self::NAME, 'Facebook'], self::VERSION], [ |
||
190 | |||
191 | '/safari\s(line)\/([\w\.]+)/i', // Line App for iOS |
||
192 | '/android.+(line)\/([\w\.]+)\/iab/i' // Line App for Android |
||
193 | ], [self::NAME, self::VERSION], [ |
||
194 | |||
195 | '/headlesschrome(?:\/([\w\.]+)|\s)/i' // Chrome Headless |
||
196 | ], [self::VERSION, [self::NAME, 'Chrome Headless']], [ |
||
197 | |||
198 | '/\swv\).+(chrome)\/([\w\.]+)/i' // Chrome WebView |
||
199 | ], [[self::NAME, '/(.+)/', '$1 WebView'], self::VERSION], [ |
||
200 | |||
201 | '/((?:oculus|samsung)browser)\/([\w\.]+)/i' |
||
202 | ], [[self::NAME, "/(.+(?:g|us))(.+)/", '$1 $2'], self::VERSION], [ // Oculus / Samsung Browser |
||
203 | |||
204 | '/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i' // Android Browser |
||
205 | ], [self::VERSION, [self::NAME, 'Android Browser']], [ |
||
206 | |||
207 | '/(sailfishbrowser)\/([\w\.]+)/i' // Sailfish Browser |
||
208 | ], [[self::NAME, 'Sailfish Browser'], self::VERSION], [ |
||
209 | |||
210 | '/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i' |
||
211 | // Chrome/OmniWeb/Arora/Tizen/Nokia |
||
212 | ], [self::NAME, self::VERSION], [ |
||
213 | |||
214 | '/(dolfin)\/([\w\.]+)/i' // Dolphin |
||
215 | ], [[self::NAME, 'Dolphin'], self::VERSION], [ |
||
216 | |||
217 | '/((?:android.+)crmo|crios)\/([\w\.]+)/i' // Chrome for Android/iOS |
||
218 | ], [[self::NAME, 'Chrome'], self::VERSION], [ |
||
219 | |||
220 | '/(coast)\/([\w\.]+)/i' // Opera Coast |
||
221 | ], [[self::NAME, 'Opera Coast'], self::VERSION], [ |
||
222 | |||
223 | '/fxios\/([\w\.-]+)/i' // Firefox for iOS |
||
224 | ], [self::VERSION, [self::NAME, 'Firefox']], [ |
||
225 | |||
226 | '/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i' // Mobile Safari |
||
227 | ], [self::VERSION, [self::NAME, 'Mobile Safari']], [ |
||
228 | |||
229 | '/version\/([\w\.]+).+?(mobile\s?safari|safari)/i' // Safari & Safari Mobile |
||
230 | ], [self::VERSION, self::NAME], [ |
||
231 | |||
232 | '/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i' // Google Search Appliance on iOS |
||
233 | ], [[self::NAME, 'GSA'], self::VERSION], [ |
||
234 | |||
235 | '/webkit.+?(mobile\s?safari|safari)(\/[\w]+)/i' // Safari < 3.0 |
||
236 | ], [self::NAME, [self::VERSION, '__str', 'oldsafari.version']], [ |
||
237 | |||
238 | '/(webkit|khtml)\/([\w\.]+)/i' |
||
239 | ], [self::NAME, self::VERSION], [ |
||
240 | |||
241 | // Gecko based |
||
242 | '/(navigator|netscape)\/([\w\.-]+)/i' // Netscape |
||
243 | ], [[self::NAME, 'Netscape'], self::VERSION], [ |
||
244 | '/(swiftfox)/i', // Swiftfox |
||
245 | '/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i', |
||
246 | // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror |
||
247 | '/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i', |
||
248 | |||
249 | // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix |
||
250 | '/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i', // Mozilla |
||
251 | |||
252 | // Other |
||
253 | '/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i', |
||
254 | // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir |
||
255 | '/(links)\s\(([\w\.]+)/i', // Links |
||
256 | '/(gobrowser)\/?([\w\.]*)/i', // GoBrowser |
||
257 | '/(ice\s?browser)\/v?([\w\._]+)/i', // ICE Browser |
||
258 | '/(mosaic)[\/\s]([\w\.]+)/i' // Mosaic |
||
259 | ], [self::NAME, self::VERSION], |
||
260 | ]; |
||
263 |