Passed
Push — master ( 6909b2...833ee2 )
by Josh
25:46
created

AttributeMapSafeness   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A assessSafeness() 0 16 4
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2020 The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\Traits;
9
10
use s9e\TextFormatter\Configurator\Helpers\ContextSafeness;
11
12
trait AttributeMapSafeness
13
{
14
	/**
15
	* Assess the safeness of this attribute filter based on given list of strings
16
	*
17
	* @param  string[] $strings
18
	* @return void
19
	*/
20
	protected function assessSafeness(array $strings): void
21
	{
22
		$str = implode('', $strings);
23
		foreach (['AsURL', 'InCSS', 'InJS'] as $context)
24
		{
25
			$callback = ContextSafeness::class . '::getDisallowedCharacters' . $context;
26
			foreach ($callback() as $char)
27
			{
28
				if (strpos($str, $char) !== false)
29
				{
30
					continue 2;
31
				}
32
			}
33
34
			$methodName = 'markAsSafe' . $context;
35
			$this->$methodName();
36
		}
37
	}
38
}