Completed
Pull Request — master (#69)
by Jakub
30:44 queued 28:04
created

untrusted_connection::test()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 13
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 1
crap 12
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
	public function __construct($request)
24
	{
25
		$this->request = $request;
26
	}
27
28
	/**
29
	 * {@inheritDoc}
30
	 */
31
	public function test($ad_code)
32
	{
33
		$is_https = $this->request->server('HTTPS', false);
34
		if ($is_https && preg_match('/http[^s]/', $ad_code))
35
		{
36
			return array(
37
				'warning'	=> array(
38
					'UNSECURE_CONNECTION',
39
				),
40
			);
41
		}
42
43
		return array();
44
	}
45
}
46