Completed
Pull Request — master (#69)
by Jakub
10:18
created

location_href   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 24
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 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 12
	public function run($ad_code)
24
	{
25 12
		if (preg_match('/location\.href(\s)*=/U', $ad_code))
26 12
		{
27
			return array(
28
				'warning'	=> array(
29 3
					'LOCATION_CHANGE',
30 3
				),
31 3
			);
32
		}
33
34 9
		return array();
35
	}
36
}
37