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