Completed
Push — master ( aa21ef...c68909 )
by Mark
02:02
created
src/CrawlerDetect.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     public function setHttpHeaders($httpHeaders = null)
462 462
     {
463 463
         // use global _SERVER if $httpHeaders aren't defined
464
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
464
+        if ( ! is_array($httpHeaders) || ! count($httpHeaders)) {
465 465
             $httpHeaders = $_SERVER;
466 466
         }
467 467
         // clear existing headers
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                 }
493 493
             }
494 494
 
495
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
495
+            return $this->userAgent = ( ! empty($this->userAgent) ? trim($this->userAgent) : null);
496 496
         }
497 497
     }
498 498
 
Please login to merge, or discard this patch.
Indentation   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -4,433 +4,433 @@
 block discarded – undo
4 4
 
5 5
 class CrawlerDetect
6 6
 {
7
-    /**
8
-     * The user agent.
9
-     *
10
-     * @var null
11
-     */
12
-    protected $userAgent = null;
7
+	/**
8
+	 * The user agent.
9
+	 *
10
+	 * @var null
11
+	 */
12
+	protected $userAgent = null;
13 13
 
14
-    /**
15
-     * Headers that contain a user agent.
16
-     *
17
-     * @var array
18
-     */
19
-    protected $httpHeaders = array();
14
+	/**
15
+	 * Headers that contain a user agent.
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $httpHeaders = array();
20 20
 
21
-    /**
22
-     * Store regex matches.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $matches = array();
21
+	/**
22
+	 * Store regex matches.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $matches = array();
27 27
 
28
-    /**
29
-     * List of strings to remove from the user agent before running the crawler regex
30
-     * Over a large list of user agents, this gives us about a 55% speed increase!
31
-     *
32
-     * @var array
33
-     */
34
-    protected static $ignore = array(
35
-        'Safari.[\d\.]*',
36
-        'Firefox.[\d\.]*',
37
-        'Chrome.[\d\.]*',
38
-        'Chromium.[\d\.]*',
39
-        'MSIE.[\d\.]',
40
-        'Opera\/[\d\.]*',
41
-        'Mozilla.[\d\.]*',
42
-        'AppleWebKit.[\d\.]*',
43
-        'Trident.[\d\.]*',
44
-        'Windows NT.[\d\.]*',
45
-        'Android.[\d\.]*',
46
-        'Macintosh.',
47
-        'Ubuntu',
48
-        'Linux',
49
-        '[ ]Intel',
50
-        'Mac OS X',
51
-        'Gecko.[\d\.]*',
52
-        'KHTML',
53
-        'CriOS.[\d\.]*',
54
-        'CPU iPhone OS ([0-9_])* like Mac OS X',
55
-        'CPU OS ([0-9_])* like Mac OS X',
56
-        'iPod',
57
-        'like Gecko',
58
-        'compatible',
59
-        'x86_..',
60
-        'i686',
61
-        'x64',
62
-        'X11',
63
-        'rv:[\d\.]*',
64
-        'Version.[\d\.]*',
65
-        'WOW64',
66
-        'Win64',
67
-        'Dalvik.[\d\.]*',
68
-        '\.NET CLR [\d\.]*',
69
-        'Presto.[\d\.]*',
70
-        'Media Center PC',
71
-    );
28
+	/**
29
+	 * List of strings to remove from the user agent before running the crawler regex
30
+	 * Over a large list of user agents, this gives us about a 55% speed increase!
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected static $ignore = array(
35
+		'Safari.[\d\.]*',
36
+		'Firefox.[\d\.]*',
37
+		'Chrome.[\d\.]*',
38
+		'Chromium.[\d\.]*',
39
+		'MSIE.[\d\.]',
40
+		'Opera\/[\d\.]*',
41
+		'Mozilla.[\d\.]*',
42
+		'AppleWebKit.[\d\.]*',
43
+		'Trident.[\d\.]*',
44
+		'Windows NT.[\d\.]*',
45
+		'Android.[\d\.]*',
46
+		'Macintosh.',
47
+		'Ubuntu',
48
+		'Linux',
49
+		'[ ]Intel',
50
+		'Mac OS X',
51
+		'Gecko.[\d\.]*',
52
+		'KHTML',
53
+		'CriOS.[\d\.]*',
54
+		'CPU iPhone OS ([0-9_])* like Mac OS X',
55
+		'CPU OS ([0-9_])* like Mac OS X',
56
+		'iPod',
57
+		'like Gecko',
58
+		'compatible',
59
+		'x86_..',
60
+		'i686',
61
+		'x64',
62
+		'X11',
63
+		'rv:[\d\.]*',
64
+		'Version.[\d\.]*',
65
+		'WOW64',
66
+		'Win64',
67
+		'Dalvik.[\d\.]*',
68
+		'\.NET CLR [\d\.]*',
69
+		'Presto.[\d\.]*',
70
+		'Media Center PC',
71
+	);
72 72
 
73
-    /**
74
-     * Array of regular expressions to match against the user agent.
75
-     *
76
-     * @var array
77
-     */
78
-    protected static $crawlers = array(
79
-        '008\\/',
80
-        'A6-Indexer',
81
-        'Aboundex',
82
-        'Accoona-AI-Agent',
83
-        'acoon',
84
-        'AddThis',
85
-        'ADmantX',
86
-        'AHC',
87
-        'Airmail',
88
-        'Anemone',
89
-        'Arachmo',
90
-        'archive-com',
91
-        'B-l-i-t-z-B-O-T',
92
-        'bibnum\.bnf',
93
-        'biglotron',
94
-        'binlar',
95
-        'BingPreview',
96
-        'boitho\.com-dc',
97
-        'BUbiNG',
98
-        'Butterfly\\/',
99
-        'BuzzSumo',
100
-        'CapsuleChecker',
101
-        'CC Metadata Scaper',
102
-        'Cerberian Drtrs',
103
-        'changedetection',
104
-        'Charlotte',
105
-        'clips\.ua\.ac\.be',
106
-        'CloudFlare-AlwaysOnline',
107
-        'coccoc',
108
-        'Commons-HttpClient',
109
-        'convera',
110
-        'cosmos',
111
-        'Covario-IDS',
112
-        'curl',
113
-        'CyberPatrol',
114
-        'Dragonfly File Reader',
115
-        'DataparkSearch',
116
-        'dataprovider',
117
-        'Digg',
118
-        'DomainAppender',
119
-        'drupact',
120
-        'EARTHCOM',
121
-        'ECCP',
122
-        'ec2linkfinder',
123
-        'ElectricMonk',
124
-        'Embedly',
125
-        'europarchive\.org',
126
-        'EventMachine HttpClient',
127
-        'ExactSearch',
128
-        'ezooms',
129
-        'eZ Publish Link Validator',
130
-        'facebookexternalhit',
131
-        'FeedBurner',
132
-        'Feedfetcher-Google',
133
-        'FeedValidator',
134
-        'FindLinks',
135
-        'findlink',
136
-        'findthatfile',
137
-        'Flamingo_SearchEngine',
138
-        'fluffy',
139
-        'getprismatic\.com',
140
-        'g00g1e\.net',
141
-        'GigablastOpenSource',
142
-        'grub-client',
143
-        'Genieo',
144
-        'Go-http-client',
145
-        'Google-HTTP-Java-Client',
146
-        'Google favicon',
147
-        'Google Keyword Suggestion',
148
-        'heritrix',
149
-        'Holmes',
150
-        'htdig',
151
-        'httpunit',
152
-        'httrack',
153
-        'HubSpot Marketing Grader',
154
-        'ichiro',
155
-        'infegy',
156
-        'igdeSpyder',
157
-        'InAGist',
158
-        'InfoWizards Reciprocal Link System PRO',
159
-        'integromedb',
160
-        'IODC',
161
-        'IOI',
162
-        'ips-agent',
163
-        'iZSearch',
164
-        'L\.webis',
165
-        'Larbin',
166
-        'libwww',
167
-        'Link Valet',
168
-        'linkdex',
169
-        'LinkExaminer',
170
-        'LinkWalker',
171
-        'Lipperhey Link Explorer',
172
-        'Lipperhey SEO Service',
173
-        'LongURL API',
174
-        'ltx71',
175
-        'lwp-trivial',
176
-        'MegaIndex\.ru',
177
-        'mabontland',
178
-        'MagpieRSS',
179
-        'Mediapartners-Google',
180
-        'MetaURI',
181
-        'Mnogosearch',
182
-        'mogimogi',
183
-        'Morning Paper',
184
-        'Mrcgiguy',
185
-        'MVAClient',
186
-        'Netcraft Web Server Survey',
187
-        'netresearchserver',
188
-        'NewsGator',
189
-        'newsme',
190
-        'NG-Search',
191
-        '^NING\\/',
192
-        'Notifixious',
193
-        'nutch',
194
-        'NutchCVS',
195
-        'Nymesis',
196
-        'oegp',
197
-        'Omea Reader',
198
-        'online link validator',
199
-        'Online Website Link Checker',
200
-        'Orbiter',
201
-        'ow\.ly',
202
-        'Ploetz \+ Zeller',
203
-        'page2rss',
204
-        'panscient',
205
-        'Peew',
206
-        'phpcrawl',
207
-        'Pinterest',
208
-        'Pizilla',
209
-        'Plukkie',
210
-        'Pompos',
211
-        'postano',
212
-        'PostPost',
213
-        'postrank',
214
-        'proximic',
215
-        'PycURL',
216
-        'Python-httplib2',
217
-        'python-requests',
218
-        'Python-urllib',
219
-        'Qseero',
220
-        'Qwantify',
221
-        'Radian6',
222
-        'RebelMouse',
223
-        'REL Link Checker',
224
-        'RetrevoPageAnalyzer',
225
-        'Riddler',
226
-        'Robosourcer',
227
-        'Ruby',
228
-        'SBIder',
229
-        'ScoutJet',
230
-        'ScoutURLMonitor',
231
-        'Scrapy',
232
-        'Scrubby',
233
-        'SearchSight',
234
-        'semanticdiscovery',
235
-        'SEOstats',
236
-        'Seznam screenshot-generator',
237
-        'ShopWiki',
238
-        'SiteBar',
239
-        'siteexplorer\.info',
240
-        'slider\.com',
241
-        'slurp',
242
-        'Snappy',
243
-        'sogou',
244
-        'speedy',
245
-        'Sqworm',
246
-        'StackRambler',
247
-        'Stratagems Kumo',
248
-        'summify',
249
-        'teoma',
250
-        'theoldreader\.com',
251
-        'TinEye',
252
-        'Traackr.com',
253
-        'truwoGPS',
254
-        'tweetedtimes\.com',
255
-        'Twikle',
256
-        'UdmSearch',
257
-        'UnwindFetchor',
258
-        'updated',
259
-        'urlresolver',
260
-        'Validator\.nu\\/LV',
261
-        'Vagabondo',
262
-        'Vivante Link Checker',
263
-        'Vortex',
264
-        'voyager\\/',
265
-        'VYU2',
266
-        'W3C-checklink',
267
-        'W3C_CSS_Validator_JFouffa',
268
-        'W3C_I18n-Checker',
269
-        'W3C-mobileOK',
270
-        'W3C_Unicorn',
271
-        'W3C_Validator',
272
-        'WebIndex',
273
-        'Websquash\.com',
274
-        'webcollage',
275
-        'webmon ',
276
-        'WeSEE:Search',
277
-        'wf84',
278
-        'wget',
279
-        'WomlpeFactory',
280
-        'wotbox',
281
-        'Xenu Link Sleuth',
282
-        'XML Sitemaps Generator',
283
-        'Y!J-ASR',
284
-        'yacy',
285
-        'Yahoo Ad monitoring',
286
-        'Yahoo Link Preview',
287
-        'Yahoo! Slurp China',
288
-        'Yahoo! Slurp',
289
-        'YahooSeeker',
290
-        'YahooSeeker-Testing',
291
-        'YandexImages',
292
-        'YandexMetrika',
293
-        'YandexDirectDyn',
294
-        'yandex',
295
-        'yanga',
296
-        'yeti',
297
-        'yoogliFetchAgent',
298
-        'Zao',
299
-        'ZyBorg',
300
-        '[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
301
-    );
73
+	/**
74
+	 * Array of regular expressions to match against the user agent.
75
+	 *
76
+	 * @var array
77
+	 */
78
+	protected static $crawlers = array(
79
+		'008\\/',
80
+		'A6-Indexer',
81
+		'Aboundex',
82
+		'Accoona-AI-Agent',
83
+		'acoon',
84
+		'AddThis',
85
+		'ADmantX',
86
+		'AHC',
87
+		'Airmail',
88
+		'Anemone',
89
+		'Arachmo',
90
+		'archive-com',
91
+		'B-l-i-t-z-B-O-T',
92
+		'bibnum\.bnf',
93
+		'biglotron',
94
+		'binlar',
95
+		'BingPreview',
96
+		'boitho\.com-dc',
97
+		'BUbiNG',
98
+		'Butterfly\\/',
99
+		'BuzzSumo',
100
+		'CapsuleChecker',
101
+		'CC Metadata Scaper',
102
+		'Cerberian Drtrs',
103
+		'changedetection',
104
+		'Charlotte',
105
+		'clips\.ua\.ac\.be',
106
+		'CloudFlare-AlwaysOnline',
107
+		'coccoc',
108
+		'Commons-HttpClient',
109
+		'convera',
110
+		'cosmos',
111
+		'Covario-IDS',
112
+		'curl',
113
+		'CyberPatrol',
114
+		'Dragonfly File Reader',
115
+		'DataparkSearch',
116
+		'dataprovider',
117
+		'Digg',
118
+		'DomainAppender',
119
+		'drupact',
120
+		'EARTHCOM',
121
+		'ECCP',
122
+		'ec2linkfinder',
123
+		'ElectricMonk',
124
+		'Embedly',
125
+		'europarchive\.org',
126
+		'EventMachine HttpClient',
127
+		'ExactSearch',
128
+		'ezooms',
129
+		'eZ Publish Link Validator',
130
+		'facebookexternalhit',
131
+		'FeedBurner',
132
+		'Feedfetcher-Google',
133
+		'FeedValidator',
134
+		'FindLinks',
135
+		'findlink',
136
+		'findthatfile',
137
+		'Flamingo_SearchEngine',
138
+		'fluffy',
139
+		'getprismatic\.com',
140
+		'g00g1e\.net',
141
+		'GigablastOpenSource',
142
+		'grub-client',
143
+		'Genieo',
144
+		'Go-http-client',
145
+		'Google-HTTP-Java-Client',
146
+		'Google favicon',
147
+		'Google Keyword Suggestion',
148
+		'heritrix',
149
+		'Holmes',
150
+		'htdig',
151
+		'httpunit',
152
+		'httrack',
153
+		'HubSpot Marketing Grader',
154
+		'ichiro',
155
+		'infegy',
156
+		'igdeSpyder',
157
+		'InAGist',
158
+		'InfoWizards Reciprocal Link System PRO',
159
+		'integromedb',
160
+		'IODC',
161
+		'IOI',
162
+		'ips-agent',
163
+		'iZSearch',
164
+		'L\.webis',
165
+		'Larbin',
166
+		'libwww',
167
+		'Link Valet',
168
+		'linkdex',
169
+		'LinkExaminer',
170
+		'LinkWalker',
171
+		'Lipperhey Link Explorer',
172
+		'Lipperhey SEO Service',
173
+		'LongURL API',
174
+		'ltx71',
175
+		'lwp-trivial',
176
+		'MegaIndex\.ru',
177
+		'mabontland',
178
+		'MagpieRSS',
179
+		'Mediapartners-Google',
180
+		'MetaURI',
181
+		'Mnogosearch',
182
+		'mogimogi',
183
+		'Morning Paper',
184
+		'Mrcgiguy',
185
+		'MVAClient',
186
+		'Netcraft Web Server Survey',
187
+		'netresearchserver',
188
+		'NewsGator',
189
+		'newsme',
190
+		'NG-Search',
191
+		'^NING\\/',
192
+		'Notifixious',
193
+		'nutch',
194
+		'NutchCVS',
195
+		'Nymesis',
196
+		'oegp',
197
+		'Omea Reader',
198
+		'online link validator',
199
+		'Online Website Link Checker',
200
+		'Orbiter',
201
+		'ow\.ly',
202
+		'Ploetz \+ Zeller',
203
+		'page2rss',
204
+		'panscient',
205
+		'Peew',
206
+		'phpcrawl',
207
+		'Pinterest',
208
+		'Pizilla',
209
+		'Plukkie',
210
+		'Pompos',
211
+		'postano',
212
+		'PostPost',
213
+		'postrank',
214
+		'proximic',
215
+		'PycURL',
216
+		'Python-httplib2',
217
+		'python-requests',
218
+		'Python-urllib',
219
+		'Qseero',
220
+		'Qwantify',
221
+		'Radian6',
222
+		'RebelMouse',
223
+		'REL Link Checker',
224
+		'RetrevoPageAnalyzer',
225
+		'Riddler',
226
+		'Robosourcer',
227
+		'Ruby',
228
+		'SBIder',
229
+		'ScoutJet',
230
+		'ScoutURLMonitor',
231
+		'Scrapy',
232
+		'Scrubby',
233
+		'SearchSight',
234
+		'semanticdiscovery',
235
+		'SEOstats',
236
+		'Seznam screenshot-generator',
237
+		'ShopWiki',
238
+		'SiteBar',
239
+		'siteexplorer\.info',
240
+		'slider\.com',
241
+		'slurp',
242
+		'Snappy',
243
+		'sogou',
244
+		'speedy',
245
+		'Sqworm',
246
+		'StackRambler',
247
+		'Stratagems Kumo',
248
+		'summify',
249
+		'teoma',
250
+		'theoldreader\.com',
251
+		'TinEye',
252
+		'Traackr.com',
253
+		'truwoGPS',
254
+		'tweetedtimes\.com',
255
+		'Twikle',
256
+		'UdmSearch',
257
+		'UnwindFetchor',
258
+		'updated',
259
+		'urlresolver',
260
+		'Validator\.nu\\/LV',
261
+		'Vagabondo',
262
+		'Vivante Link Checker',
263
+		'Vortex',
264
+		'voyager\\/',
265
+		'VYU2',
266
+		'W3C-checklink',
267
+		'W3C_CSS_Validator_JFouffa',
268
+		'W3C_I18n-Checker',
269
+		'W3C-mobileOK',
270
+		'W3C_Unicorn',
271
+		'W3C_Validator',
272
+		'WebIndex',
273
+		'Websquash\.com',
274
+		'webcollage',
275
+		'webmon ',
276
+		'WeSEE:Search',
277
+		'wf84',
278
+		'wget',
279
+		'WomlpeFactory',
280
+		'wotbox',
281
+		'Xenu Link Sleuth',
282
+		'XML Sitemaps Generator',
283
+		'Y!J-ASR',
284
+		'yacy',
285
+		'Yahoo Ad monitoring',
286
+		'Yahoo Link Preview',
287
+		'Yahoo! Slurp China',
288
+		'Yahoo! Slurp',
289
+		'YahooSeeker',
290
+		'YahooSeeker-Testing',
291
+		'YandexImages',
292
+		'YandexMetrika',
293
+		'YandexDirectDyn',
294
+		'yandex',
295
+		'yanga',
296
+		'yeti',
297
+		'yoogliFetchAgent',
298
+		'Zao',
299
+		'ZyBorg',
300
+		'[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
301
+	);
302 302
 
303
-    /**
304
-     * All possible HTTP headers that represent the
305
-     * User-Agent string.
306
-     *
307
-     * @var array
308
-     */
309
-    protected static $uaHttpHeaders = array(
310
-        // The default User-Agent string.
311
-        'HTTP_USER_AGENT',
312
-        // Header can occur on devices using Opera Mini.
313
-        'HTTP_X_OPERAMINI_PHONE_UA',
314
-        // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
315
-        'HTTP_X_DEVICE_USER_AGENT',
316
-        'HTTP_X_ORIGINAL_USER_AGENT',
317
-        'HTTP_X_SKYFIRE_PHONE',
318
-        'HTTP_X_BOLT_PHONE_UA',
319
-        'HTTP_DEVICE_STOCK_UA',
320
-        'HTTP_X_UCBROWSER_DEVICE_UA',
321
-    );
303
+	/**
304
+	 * All possible HTTP headers that represent the
305
+	 * User-Agent string.
306
+	 *
307
+	 * @var array
308
+	 */
309
+	protected static $uaHttpHeaders = array(
310
+		// The default User-Agent string.
311
+		'HTTP_USER_AGENT',
312
+		// Header can occur on devices using Opera Mini.
313
+		'HTTP_X_OPERAMINI_PHONE_UA',
314
+		// Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
315
+		'HTTP_X_DEVICE_USER_AGENT',
316
+		'HTTP_X_ORIGINAL_USER_AGENT',
317
+		'HTTP_X_SKYFIRE_PHONE',
318
+		'HTTP_X_BOLT_PHONE_UA',
319
+		'HTTP_DEVICE_STOCK_UA',
320
+		'HTTP_X_UCBROWSER_DEVICE_UA',
321
+	);
322 322
 
323
-    /**
324
-     * Class constructor.
325
-     */
326
-    public function __construct(array $headers = null, $userAgent = null)
327
-    {
328
-        $this->setHttpHeaders($headers);
329
-        $this->setUserAgent($userAgent);
330
-    }
323
+	/**
324
+	 * Class constructor.
325
+	 */
326
+	public function __construct(array $headers = null, $userAgent = null)
327
+	{
328
+		$this->setHttpHeaders($headers);
329
+		$this->setUserAgent($userAgent);
330
+	}
331 331
 
332
-    /**
333
-     * Set HTTP headers.
334
-     *
335
-     * @param array $httpHeaders
336
-     */
337
-    public function setHttpHeaders($httpHeaders = null)
338
-    {
339
-        // use global _SERVER if $httpHeaders aren't defined
340
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
341
-            $httpHeaders = $_SERVER;
342
-        }
343
-        // clear existing headers
344
-        $this->httpHeaders = array();
345
-        // Only save HTTP headers. In PHP land, that means only _SERVER vars that
346
-        // start with HTTP_.
347
-        foreach ($httpHeaders as $key => $value) {
348
-            if (substr($key, 0, 5) === 'HTTP_') {
349
-                $this->httpHeaders[$key] = $value;
350
-            }
351
-        }
352
-    }
332
+	/**
333
+	 * Set HTTP headers.
334
+	 *
335
+	 * @param array $httpHeaders
336
+	 */
337
+	public function setHttpHeaders($httpHeaders = null)
338
+	{
339
+		// use global _SERVER if $httpHeaders aren't defined
340
+		if (!is_array($httpHeaders) || !count($httpHeaders)) {
341
+			$httpHeaders = $_SERVER;
342
+		}
343
+		// clear existing headers
344
+		$this->httpHeaders = array();
345
+		// Only save HTTP headers. In PHP land, that means only _SERVER vars that
346
+		// start with HTTP_.
347
+		foreach ($httpHeaders as $key => $value) {
348
+			if (substr($key, 0, 5) === 'HTTP_') {
349
+				$this->httpHeaders[$key] = $value;
350
+			}
351
+		}
352
+	}
353 353
 
354
-    /**
355
-     * Return user agent headers.
356
-     *
357
-     * @return array
358
-     */
359
-    public function getUaHttpHeaders()
360
-    {
361
-        return self::$uaHttpHeaders;
362
-    }
354
+	/**
355
+	 * Return user agent headers.
356
+	 *
357
+	 * @return array
358
+	 */
359
+	public function getUaHttpHeaders()
360
+	{
361
+		return self::$uaHttpHeaders;
362
+	}
363 363
 
364
-    /**
365
-     * Set the user agent.
366
-     *
367
-     * @param string $userAgent
368
-     */
369
-    public function setUserAgent($userAgent = null)
370
-    {
371
-        if (false === empty($userAgent)) {
372
-            return $this->userAgent = $userAgent;
373
-        } else {
374
-            $this->userAgent = null;
375
-            foreach ($this->getUaHttpHeaders() as $altHeader) {
376
-                if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
377
-                    $this->userAgent .= $this->httpHeaders[$altHeader].' ';
378
-                }
379
-            }
364
+	/**
365
+	 * Set the user agent.
366
+	 *
367
+	 * @param string $userAgent
368
+	 */
369
+	public function setUserAgent($userAgent = null)
370
+	{
371
+		if (false === empty($userAgent)) {
372
+			return $this->userAgent = $userAgent;
373
+		} else {
374
+			$this->userAgent = null;
375
+			foreach ($this->getUaHttpHeaders() as $altHeader) {
376
+				if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
377
+					$this->userAgent .= $this->httpHeaders[$altHeader].' ';
378
+				}
379
+			}
380 380
 
381
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
382
-        }
383
-    }
381
+			return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
382
+		}
383
+	}
384 384
 
385
-    /**
386
-     * Build the user agent regex.
387
-     *
388
-     * @return string
389
-     */
390
-    public function getRegex()
391
-    {
392
-        return '('.implode('|', self::$crawlers).')';
393
-    }
385
+	/**
386
+	 * Build the user agent regex.
387
+	 *
388
+	 * @return string
389
+	 */
390
+	public function getRegex()
391
+	{
392
+		return '('.implode('|', self::$crawlers).')';
393
+	}
394 394
 
395
-    /**
396
-     * Build the replacement regex.
397
-     *
398
-     * @return string
399
-     */
400
-    public function getIgnored()
401
-    {
402
-        return '('.implode('|', self::$ignore).')';
403
-    }
395
+	/**
396
+	 * Build the replacement regex.
397
+	 *
398
+	 * @return string
399
+	 */
400
+	public function getIgnored()
401
+	{
402
+		return '('.implode('|', self::$ignore).')';
403
+	}
404 404
 
405
-    /**
406
-     * Check user agent string against the regex.
407
-     *
408
-     * @param string $userAgent
409
-     *
410
-     * @return bool
411
-     */
412
-    public function isCrawler($userAgent = null)
413
-    {
414
-        $agent = is_null($userAgent) ? $this->userAgent : $userAgent;
405
+	/**
406
+	 * Check user agent string against the regex.
407
+	 *
408
+	 * @param string $userAgent
409
+	 *
410
+	 * @return bool
411
+	 */
412
+	public function isCrawler($userAgent = null)
413
+	{
414
+		$agent = is_null($userAgent) ? $this->userAgent : $userAgent;
415 415
 
416
-        $agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
416
+		$agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
417 417
 
418
-        $result = preg_match('/'.$this->getRegex().'/i', $agent, $matches);
418
+		$result = preg_match('/'.$this->getRegex().'/i', $agent, $matches);
419 419
 
420
-        if ($matches) {
421
-            $this->matches = $matches;
422
-        }
420
+		if ($matches) {
421
+			$this->matches = $matches;
422
+		}
423 423
 
424
-        return (bool) $result;
425
-    }
424
+		return (bool) $result;
425
+	}
426 426
 
427
-    /**
428
-     * Return the matches.
429
-     *
430
-     * @return string
431
-     */
432
-    public function getMatches()
433
-    {
434
-        return $this->matches[0];
435
-    }
427
+	/**
428
+	 * Return the matches.
429
+	 *
430
+	 * @return string
431
+	 */
432
+	public function getMatches()
433
+	{
434
+		return $this->matches[0];
435
+	}
436 436
 }
Please login to merge, or discard this patch.
tests/UATests.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -2,39 +2,39 @@
 block discarded – undo
2 2
 
3 3
 class UserAgentTest extends PHPUnit_Framework_TestCase
4 4
 {
5
-    protected $CrawlerDetect;
5
+	protected $CrawlerDetect;
6 6
 
7
-    public function setUp()
8
-    {
9
-        $this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect();
10
-    }
7
+	public function setUp()
8
+	{
9
+		$this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect();
10
+	}
11 11
 
12
-    public function testBots()
13
-    {
14
-        $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
12
+	public function testBots()
13
+	{
14
+		$lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
15 15
 
16
-        foreach ($lines as $line) {
17
-            $test = $this->CrawlerDetect->isCrawler($line);
18
-            $this->assertEquals($test, true, $line);
19
-        }
20
-    }
16
+		foreach ($lines as $line) {
17
+			$test = $this->CrawlerDetect->isCrawler($line);
18
+			$this->assertEquals($test, true, $line);
19
+		}
20
+	}
21 21
 
22
-    public function testDevices()
23
-    {
24
-        $lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
22
+	public function testDevices()
23
+	{
24
+		$lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
25 25
 
26
-        foreach ($lines as $line) {
27
-            $test = $this->CrawlerDetect->isCrawler($line);
28
-            $this->assertEquals($test, false, $line);
29
-        }
30
-    }
26
+		foreach ($lines as $line) {
27
+			$test = $this->CrawlerDetect->isCrawler($line);
28
+			$this->assertEquals($test, false, $line);
29
+		}
30
+	}
31 31
 
32
-    public function testReturnsCorrectMatchedBotName()
33
-    {
34
-        $test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)');
32
+	public function testReturnsCorrectMatchedBotName()
33
+	{
34
+		$test = $this->CrawlerDetect->isCrawler('Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile (compatible; Yahoo Ad monitoring; https://help.yahoo.com/kb/yahoo-ad-monitoring-SLN24857.html)');
35 35
 
36
-        $matches = $this->CrawlerDetect->getMatches();
36
+		$matches = $this->CrawlerDetect->getMatches();
37 37
 
38
-        $this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches);
39
-    }
38
+		$this->assertEquals($this->CrawlerDetect->getMatches(), 'Yahoo Ad monitoring', $matches);
39
+	}
40 40
 }
Please login to merge, or discard this patch.