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

script_without_async::test()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 12
cts 12
cp 1
rs 9.2
cc 4
eloc 8
nc 3
nop 1
crap 4
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 script_without_async implements test_interface
14
{
15
	/**
16
	 * {@inheritDoc}
17
	 */
18 12
	public function test($ad_code)
19
	{
20 12
		if (preg_match_all('/&lt;script(.*)&gt;/U', $ad_code, $matches))
21 12
		{
22 12
			foreach ($matches[1] as $match)
23
			{
24 12
				if (!preg_match('/ async/', $match))
25 12
				{
26
					return array(
27
						'notice'	=> array(
28 5
							'SCRIPT_WITHOUT_ASYNC',
29 5
						),
30 5
					);
31
				}
32 8
			}
33 7
		}
34
35 7
		return array();
36
	}
37
}
38