Completed
Pull Request — master (#69)
by Jakub
21:27 queued 10:37
created

untrusted_connection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A test() 0 14 3
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 untrusted_connection implements test_interface
14
{
15
	/** @var \phpbb\request\request */
16
	protected $request;
17
18
	/**
19
	 * Construct an ad code analysis manager object
20
	 *
21
	 * @param \phpbb\request\request $request Request object
22
	 */
23 12
	public function __construct(\phpbb\request\request $request)
24
	{
25 12
		$this->request = $request;
26 12
	}
27
28
	/**
29
	 * {@inheritDoc}
30
	 */
31 12
	public function test($ad_code)
32
	{
33 12
		$is_https = $this->request->server('HTTPS', false);
34 12
		if ($is_https && preg_match('/http[^s]/', $ad_code))
35 12
		{
36
			return array(
37
				'warning'	=> array(
38 2
					'UNSECURE_CONNECTION',
39 2
				),
40 2
			);
41
		}
42
43 10
		return array();
44
	}
45
}
46