location_href   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 21
rs 10
ccs 7
cts 7
cp 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 11 2
1
<?php
2
/**
3
 *
4
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ads\analyser\test;
12
13
class location_href implements test_interface
14
{
15
	/**
16
	 * {@inheritDoc}
17
	 *
18
	 * Javascript redirect using window.location.href test.
19
	 * This test checks for the presence of redirect in an ad code.
20
	 * There is no reason why ad would redirect user to another page,
21
	 * so it's categorized as warning.
22
	 */
23 13
	public function run($ad_code)
24
	{
25 13
		if (preg_match('/location\.href(\s)*=/U', $ad_code))
26 13
		{
27
			return array(
28 3
				'severity'	=> 'warning',
29 3
				'message'	=> 'LOCATION_CHANGE',
30 3
			);
31
		}
32
33 10
		return false;
34
	}
35
}
36