Completed
Push — master ( 9458ed...7d322b )
by Henry
10:04
created

Password::sanitize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace Redaxscript\Filter;
3
4
use function preg_replace;
5
6
/**
7
 * children class to filter the password
8
 *
9
 * @since 4.3.0
10
 *
11
 * @package Redaxscript
12
 * @category Filter
13
 * @author Henry Ruhs
14
 */
15
16
class Password implements FilterInterface
17
{
18
	/**
19
	 * pattern for password
20
	 *
21
	 * @var string
22
	 */
23
24
	protected $_pattern = '[^\S]';
25
26
	/**
27
	 * sanitize the password
28
	 *
29
	 * @since 4.3.0
30
	 *
31
	 * @param string $password plain password
32
	 *
33
	 * @return string
34
	 */
35
36
	public function sanitize(string $password = null) : string
37
	{
38
		return preg_replace('/' . $this->_pattern . '/i', null, $password);
39
	}
40
}
41