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