User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A sanitize() 0 4 2
1
<?php
2
namespace Redaxscript\Filter;
3
4
use function preg_replace;
5
use function trim;
6
7
/**
8
 * children class to filter the user
9
 *
10
 * @since 4.3.0
11
 *
12
 * @package Redaxscript
13
 * @category Filter
14
 * @author Henry Ruhs
15
 */
16
17
class User implements FilterInterface
18
{
19
	/**
20
	 * pattern for user
21
	 *
22
	 * @var string
23
	 */
24
25
	protected $_pattern = '[^a-zA-Z0-9\._-]';
26
27
	/**
28
	 * sanitize the user
29
	 *
30
	 * @since 4.3.0
31
	 *
32
	 * @param string $user user to be sanitized
33
	 *
34
	 * @return string|null
35
	 */
36
37 8
	public function sanitize(string $user = null) : ?string
38
	{
39 8
		return trim(preg_replace('/' . $this->_pattern . '/i', null, $user)) ? : null;
40
	}
41
}
42