Completed
Push — master ( 87cd42...652d2f )
by Mark
02:22
created
src/CrawlerDetect.php 1 patch
Indentation   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -4,427 +4,427 @@
 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
-        'DataparkSearch',
115
-        'dataprovider',
116
-        'Digg',
117
-        'DomainAppender',
118
-        'drupact',
119
-        'EARTHCOM',
120
-        'ECCP',
121
-        'ec2linkfinder',
122
-        'ElectricMonk',
123
-        'Embedly',
124
-        'europarchive\.org',
125
-        'EventMachine HttpClient',
126
-        'ezooms',
127
-        'eZ Publish Link Validator',
128
-        'facebookexternalhit',
129
-        'Feedfetcher-Google',
130
-        'FeedValidator',
131
-        'FindLinks',
132
-        'findlink',
133
-        'findthatfile',
134
-        'Flamingo_SearchEngine',
135
-        'fluffy',
136
-        'getprismatic\.com',
137
-        'g00g1e\.net',
138
-        'GigablastOpenSource',
139
-        'grub-client',
140
-        'Genieo',
141
-        'Go-http-client',
142
-        'Google-HTTP-Java-Client',
143
-        'Google favicon',
144
-        'Google Keyword Suggestion',
145
-        'heritrix',
146
-        'Holmes',
147
-        'htdig',
148
-        'httpunit',
149
-        'httrack',
150
-        'HubSpot Marketing Grader',
151
-        'ichiro',
152
-        'infegy',
153
-        'igdeSpyder',
154
-        'InAGist',
155
-        'InfoWizards Reciprocal Link System PRO',
156
-        'integromedb',
157
-        'IODC',
158
-        'IOI',
159
-        'ips-agent',
160
-        'iZSearch',
161
-        'L\.webis',
162
-        'Larbin',
163
-        'libwww',
164
-        'Link Valet',
165
-        'linkdex',
166
-        'LinkExaminer',
167
-        'LinkWalker',
168
-        'Lipperhey Link Explorer',
169
-        'Lipperhey SEO Service',
170
-        'LongURL API',
171
-        'ltx71',
172
-        'lwp-trivial',
173
-        'MegaIndex\.ru',
174
-        'mabontland',
175
-        'MagpieRSS',
176
-        'Mediapartners-Google',
177
-        'MetaURI',
178
-        'Mnogosearch',
179
-        'mogimogi',
180
-        'Morning Paper',
181
-        'Mrcgiguy',
182
-        'MVAClient',
183
-        'Netcraft Web Server Survey',
184
-        'netresearchserver',
185
-        'NewsGator',
186
-        'newsme',
187
-        'NG-Search',
188
-        '^NING\\/',
189
-        'Notifixious',
190
-        'nutch',
191
-        'NutchCVS',
192
-        'Nymesis',
193
-        'oegp',
194
-        'online link validator',
195
-        'Online Website Link Checker',
196
-        'Orbiter',
197
-        'ow\.ly',
198
-        'Ploetz \+ Zeller',
199
-        'page2rss',
200
-        'panscient',
201
-        'Peew',
202
-        'phpcrawl',
203
-        'Pizilla',
204
-        'Plukkie',
205
-        'Pompos',
206
-        'postano',
207
-        'PostPost',
208
-        'postrank',
209
-        'proximic',
210
-        'PycURL',
211
-        'Python-httplib2',
212
-        'python-requests',
213
-        'Python-urllib',
214
-        'Qseero',
215
-        'Qwantify',
216
-        'Radian6',
217
-        'RebelMouse',
218
-        'REL Link Checker',
219
-        'RetrevoPageAnalyzer',
220
-        'Riddler',
221
-        'Robosourcer',
222
-        'Ruby',
223
-        'SBIder',
224
-        'ScoutJet',
225
-        'ScoutURLMonitor',
226
-        'Scrapy',
227
-        'Scrubby',
228
-        'SearchSight',
229
-        'semanticdiscovery',
230
-        'SEOstats',
231
-        'Seznam screenshot-generator',
232
-        'ShopWiki',
233
-        'SiteBar',
234
-        'siteexplorer\.info',
235
-        'slider\.com',
236
-        'slurp',
237
-        'Snappy',
238
-        'sogou',
239
-        'speedy',
240
-        'Sqworm',
241
-        'StackRambler',
242
-        'Stratagems Kumo',
243
-        'summify',
244
-        'teoma',
245
-        'theoldreader\.com',
246
-        'TinEye',
247
-        'Traackr.com',
248
-        'truwoGPS',
249
-        'tweetedtimes\.com',
250
-        'Twikle',
251
-        'UnwindFetchor',
252
-        'updated',
253
-        'urlresolver',
254
-        'Validator\.nu\\/LV',
255
-        'Vagabondo',
256
-        'Vivante Link Checker',
257
-        'Vortex',
258
-        'voyager\\/',
259
-        'VYU2',
260
-        'W3C-checklink',
261
-        'W3C_CSS_Validator_JFouffa',
262
-        'W3C_I18n-Checker',
263
-        'W3C-mobileOK',
264
-        'W3C_Unicorn',
265
-        'W3C_Validator',
266
-        'WebIndex',
267
-        'Websquash\.com',
268
-        'webcollage',
269
-        'webmon ',
270
-        'WeSEE:Search',
271
-        'wf84',
272
-        'wget',
273
-        'WomlpeFactory',
274
-        'wotbox',
275
-        'Xenu Link Sleuth',
276
-        'XML Sitemaps Generator',
277
-        'Y!J-ASR',
278
-        'yacy',
279
-        'Yahoo Ad monitoring',
280
-        'Yahoo Link Preview',
281
-        'Yahoo! Slurp China',
282
-        'Yahoo! Slurp',
283
-        'YahooSeeker',
284
-        'YahooSeeker-Testing',
285
-        'YandexImages',
286
-        'YandexMetrika',
287
-        'YandexDirectDyn',
288
-        'yandex',
289
-        'yanga',
290
-        'yeti',
291
-        'yoogliFetchAgent',
292
-        'Zao',
293
-        'ZyBorg',
294
-        '[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
295
-    );
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
+		'DataparkSearch',
115
+		'dataprovider',
116
+		'Digg',
117
+		'DomainAppender',
118
+		'drupact',
119
+		'EARTHCOM',
120
+		'ECCP',
121
+		'ec2linkfinder',
122
+		'ElectricMonk',
123
+		'Embedly',
124
+		'europarchive\.org',
125
+		'EventMachine HttpClient',
126
+		'ezooms',
127
+		'eZ Publish Link Validator',
128
+		'facebookexternalhit',
129
+		'Feedfetcher-Google',
130
+		'FeedValidator',
131
+		'FindLinks',
132
+		'findlink',
133
+		'findthatfile',
134
+		'Flamingo_SearchEngine',
135
+		'fluffy',
136
+		'getprismatic\.com',
137
+		'g00g1e\.net',
138
+		'GigablastOpenSource',
139
+		'grub-client',
140
+		'Genieo',
141
+		'Go-http-client',
142
+		'Google-HTTP-Java-Client',
143
+		'Google favicon',
144
+		'Google Keyword Suggestion',
145
+		'heritrix',
146
+		'Holmes',
147
+		'htdig',
148
+		'httpunit',
149
+		'httrack',
150
+		'HubSpot Marketing Grader',
151
+		'ichiro',
152
+		'infegy',
153
+		'igdeSpyder',
154
+		'InAGist',
155
+		'InfoWizards Reciprocal Link System PRO',
156
+		'integromedb',
157
+		'IODC',
158
+		'IOI',
159
+		'ips-agent',
160
+		'iZSearch',
161
+		'L\.webis',
162
+		'Larbin',
163
+		'libwww',
164
+		'Link Valet',
165
+		'linkdex',
166
+		'LinkExaminer',
167
+		'LinkWalker',
168
+		'Lipperhey Link Explorer',
169
+		'Lipperhey SEO Service',
170
+		'LongURL API',
171
+		'ltx71',
172
+		'lwp-trivial',
173
+		'MegaIndex\.ru',
174
+		'mabontland',
175
+		'MagpieRSS',
176
+		'Mediapartners-Google',
177
+		'MetaURI',
178
+		'Mnogosearch',
179
+		'mogimogi',
180
+		'Morning Paper',
181
+		'Mrcgiguy',
182
+		'MVAClient',
183
+		'Netcraft Web Server Survey',
184
+		'netresearchserver',
185
+		'NewsGator',
186
+		'newsme',
187
+		'NG-Search',
188
+		'^NING\\/',
189
+		'Notifixious',
190
+		'nutch',
191
+		'NutchCVS',
192
+		'Nymesis',
193
+		'oegp',
194
+		'online link validator',
195
+		'Online Website Link Checker',
196
+		'Orbiter',
197
+		'ow\.ly',
198
+		'Ploetz \+ Zeller',
199
+		'page2rss',
200
+		'panscient',
201
+		'Peew',
202
+		'phpcrawl',
203
+		'Pizilla',
204
+		'Plukkie',
205
+		'Pompos',
206
+		'postano',
207
+		'PostPost',
208
+		'postrank',
209
+		'proximic',
210
+		'PycURL',
211
+		'Python-httplib2',
212
+		'python-requests',
213
+		'Python-urllib',
214
+		'Qseero',
215
+		'Qwantify',
216
+		'Radian6',
217
+		'RebelMouse',
218
+		'REL Link Checker',
219
+		'RetrevoPageAnalyzer',
220
+		'Riddler',
221
+		'Robosourcer',
222
+		'Ruby',
223
+		'SBIder',
224
+		'ScoutJet',
225
+		'ScoutURLMonitor',
226
+		'Scrapy',
227
+		'Scrubby',
228
+		'SearchSight',
229
+		'semanticdiscovery',
230
+		'SEOstats',
231
+		'Seznam screenshot-generator',
232
+		'ShopWiki',
233
+		'SiteBar',
234
+		'siteexplorer\.info',
235
+		'slider\.com',
236
+		'slurp',
237
+		'Snappy',
238
+		'sogou',
239
+		'speedy',
240
+		'Sqworm',
241
+		'StackRambler',
242
+		'Stratagems Kumo',
243
+		'summify',
244
+		'teoma',
245
+		'theoldreader\.com',
246
+		'TinEye',
247
+		'Traackr.com',
248
+		'truwoGPS',
249
+		'tweetedtimes\.com',
250
+		'Twikle',
251
+		'UnwindFetchor',
252
+		'updated',
253
+		'urlresolver',
254
+		'Validator\.nu\\/LV',
255
+		'Vagabondo',
256
+		'Vivante Link Checker',
257
+		'Vortex',
258
+		'voyager\\/',
259
+		'VYU2',
260
+		'W3C-checklink',
261
+		'W3C_CSS_Validator_JFouffa',
262
+		'W3C_I18n-Checker',
263
+		'W3C-mobileOK',
264
+		'W3C_Unicorn',
265
+		'W3C_Validator',
266
+		'WebIndex',
267
+		'Websquash\.com',
268
+		'webcollage',
269
+		'webmon ',
270
+		'WeSEE:Search',
271
+		'wf84',
272
+		'wget',
273
+		'WomlpeFactory',
274
+		'wotbox',
275
+		'Xenu Link Sleuth',
276
+		'XML Sitemaps Generator',
277
+		'Y!J-ASR',
278
+		'yacy',
279
+		'Yahoo Ad monitoring',
280
+		'Yahoo Link Preview',
281
+		'Yahoo! Slurp China',
282
+		'Yahoo! Slurp',
283
+		'YahooSeeker',
284
+		'YahooSeeker-Testing',
285
+		'YandexImages',
286
+		'YandexMetrika',
287
+		'YandexDirectDyn',
288
+		'yandex',
289
+		'yanga',
290
+		'yeti',
291
+		'yoogliFetchAgent',
292
+		'Zao',
293
+		'ZyBorg',
294
+		'[a-z0-9\\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider)',
295
+	);
296 296
 
297
-    /**
298
-     * All possible HTTP headers that represent the
299
-     * User-Agent string.
300
-     *
301
-     * @var array
302
-     */
303
-    protected static $uaHttpHeaders = array(
304
-        // The default User-Agent string.
305
-        'HTTP_USER_AGENT',
306
-        // Header can occur on devices using Opera Mini.
307
-        'HTTP_X_OPERAMINI_PHONE_UA',
308
-        // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
309
-        'HTTP_X_DEVICE_USER_AGENT',
310
-        'HTTP_X_ORIGINAL_USER_AGENT',
311
-        'HTTP_X_SKYFIRE_PHONE',
312
-        'HTTP_X_BOLT_PHONE_UA',
313
-        'HTTP_DEVICE_STOCK_UA',
314
-        'HTTP_X_UCBROWSER_DEVICE_UA',
315
-    );
297
+	/**
298
+	 * All possible HTTP headers that represent the
299
+	 * User-Agent string.
300
+	 *
301
+	 * @var array
302
+	 */
303
+	protected static $uaHttpHeaders = array(
304
+		// The default User-Agent string.
305
+		'HTTP_USER_AGENT',
306
+		// Header can occur on devices using Opera Mini.
307
+		'HTTP_X_OPERAMINI_PHONE_UA',
308
+		// Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
309
+		'HTTP_X_DEVICE_USER_AGENT',
310
+		'HTTP_X_ORIGINAL_USER_AGENT',
311
+		'HTTP_X_SKYFIRE_PHONE',
312
+		'HTTP_X_BOLT_PHONE_UA',
313
+		'HTTP_DEVICE_STOCK_UA',
314
+		'HTTP_X_UCBROWSER_DEVICE_UA',
315
+	);
316 316
 
317
-    /**
318
-     * Class constructor.
319
-     */
320
-    public function __construct(array $headers = null, $userAgent = null)
321
-    {
322
-        $this->setHttpHeaders($headers);
323
-        $this->setUserAgent($userAgent);
324
-    }
317
+	/**
318
+	 * Class constructor.
319
+	 */
320
+	public function __construct(array $headers = null, $userAgent = null)
321
+	{
322
+		$this->setHttpHeaders($headers);
323
+		$this->setUserAgent($userAgent);
324
+	}
325 325
 
326
-    /**
327
-     * Set HTTP headers.
328
-     *
329
-     * @param array $httpHeaders
330
-     */
331
-    public function setHttpHeaders($httpHeaders = null)
332
-    {
333
-        // use global _SERVER if $httpHeaders aren't defined
334
-        if (!is_array($httpHeaders) || !count($httpHeaders)) {
335
-            $httpHeaders = $_SERVER;
336
-        }
337
-        // clear existing headers
338
-        $this->httpHeaders = array();
339
-        // Only save HTTP headers. In PHP land, that means only _SERVER vars that
340
-        // start with HTTP_.
341
-        foreach ($httpHeaders as $key => $value) {
342
-            if (substr($key, 0, 5) === 'HTTP_') {
343
-                $this->httpHeaders[$key] = $value;
344
-            }
345
-        }
346
-    }
326
+	/**
327
+	 * Set HTTP headers.
328
+	 *
329
+	 * @param array $httpHeaders
330
+	 */
331
+	public function setHttpHeaders($httpHeaders = null)
332
+	{
333
+		// use global _SERVER if $httpHeaders aren't defined
334
+		if (!is_array($httpHeaders) || !count($httpHeaders)) {
335
+			$httpHeaders = $_SERVER;
336
+		}
337
+		// clear existing headers
338
+		$this->httpHeaders = array();
339
+		// Only save HTTP headers. In PHP land, that means only _SERVER vars that
340
+		// start with HTTP_.
341
+		foreach ($httpHeaders as $key => $value) {
342
+			if (substr($key, 0, 5) === 'HTTP_') {
343
+				$this->httpHeaders[$key] = $value;
344
+			}
345
+		}
346
+	}
347 347
 
348
-    /**
349
-     * Return user agent headers.
350
-     *
351
-     * @return array
352
-     */
353
-    public function getUaHttpHeaders()
354
-    {
355
-        return self::$uaHttpHeaders;
356
-    }
348
+	/**
349
+	 * Return user agent headers.
350
+	 *
351
+	 * @return array
352
+	 */
353
+	public function getUaHttpHeaders()
354
+	{
355
+		return self::$uaHttpHeaders;
356
+	}
357 357
 
358
-    /**
359
-     * Set the user agent.
360
-     *
361
-     * @param string $userAgent
362
-     */
363
-    public function setUserAgent($userAgent = null)
364
-    {
365
-        if (false === empty($userAgent)) {
366
-            return $this->userAgent = $userAgent;
367
-        } else {
368
-            $this->userAgent = null;
369
-            foreach ($this->getUaHttpHeaders() as $altHeader) {
370
-                if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
371
-                    $this->userAgent .= $this->httpHeaders[$altHeader].' ';
372
-                }
373
-            }
358
+	/**
359
+	 * Set the user agent.
360
+	 *
361
+	 * @param string $userAgent
362
+	 */
363
+	public function setUserAgent($userAgent = null)
364
+	{
365
+		if (false === empty($userAgent)) {
366
+			return $this->userAgent = $userAgent;
367
+		} else {
368
+			$this->userAgent = null;
369
+			foreach ($this->getUaHttpHeaders() as $altHeader) {
370
+				if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow.
371
+					$this->userAgent .= $this->httpHeaders[$altHeader].' ';
372
+				}
373
+			}
374 374
 
375
-            return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
376
-        }
377
-    }
375
+			return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
376
+		}
377
+	}
378 378
 
379
-    /**
380
-     * Build the user agent regex.
381
-     *
382
-     * @return string
383
-     */
384
-    public function getRegex()
385
-    {
386
-        return '('.implode('|', self::$crawlers).')';
387
-    }
379
+	/**
380
+	 * Build the user agent regex.
381
+	 *
382
+	 * @return string
383
+	 */
384
+	public function getRegex()
385
+	{
386
+		return '('.implode('|', self::$crawlers).')';
387
+	}
388 388
 
389
-    /**
390
-     * Build the replacement regex.
391
-     *
392
-     * @return string
393
-     */
394
-    public function getIgnored()
395
-    {
396
-        return '('.implode('|', self::$ignore).')';
397
-    }
389
+	/**
390
+	 * Build the replacement regex.
391
+	 *
392
+	 * @return string
393
+	 */
394
+	public function getIgnored()
395
+	{
396
+		return '('.implode('|', self::$ignore).')';
397
+	}
398 398
 
399
-    /**
400
-     * Check user agent string against the regex.
401
-     *
402
-     * @param string $userAgent
403
-     *
404
-     * @return bool
405
-     */
406
-    public function isCrawler($userAgent = null)
407
-    {
408
-        $agent = is_null($userAgent) ? $this->userAgent : $userAgent;
399
+	/**
400
+	 * Check user agent string against the regex.
401
+	 *
402
+	 * @param string $userAgent
403
+	 *
404
+	 * @return bool
405
+	 */
406
+	public function isCrawler($userAgent = null)
407
+	{
408
+		$agent = is_null($userAgent) ? $this->userAgent : $userAgent;
409 409
 
410
-        $agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
410
+		$agent = preg_replace('/'.$this->getIgnored().'/i', '', $agent);
411 411
 
412
-        $result = preg_match('/'.$this->getRegex().'/i', $agent, $matches);
412
+		$result = preg_match('/'.$this->getRegex().'/i', $agent, $matches);
413 413
 
414
-        if ($matches) {
415
-            $this->matches = $matches;
416
-        }
414
+		if ($matches) {
415
+			$this->matches = $matches;
416
+		}
417 417
 
418
-        return (bool) $result;
419
-    }
418
+		return (bool) $result;
419
+	}
420 420
 
421
-    /**
422
-     * Return the matches.
423
-     *
424
-     * @return string
425
-     */
426
-    public function getMatches()
427
-    {
428
-        return $this->matches[0];
429
-    }
421
+	/**
422
+	 * Return the matches.
423
+	 *
424
+	 * @return string
425
+	 */
426
+	public function getMatches()
427
+	{
428
+		return $this->matches[0];
429
+	}
430 430
 }
Please login to merge, or discard this patch.