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

Name   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPattern() 0 4 1
A validate() 0 4 1
1
<?php
2
namespace Redaxscript\Validator;
3
4
use function preg_match;
5
6
/**
7
 * children class to validate name
8
 *
9
 * @since 4.3.0
10
 *
11
 * @package Redaxscript
12
 * @category Validator
13
 * @author Henry Ruhs
14
 */
15
16
class Name implements ValidatorInterface
17
{
18
	/**
19
	 * pattern for name
20
	 *
21
	 * @var string
22
	 */
23
24
	protected $_pattern = '^(([a-zA-Z0-9]\s)*([a-zA-Z0-9])){3,100}$';
25
26
	/**
27
	 * get the pattern
28
	 *
29
	 * @since 4.3.0
30
	 *
31
	 * @return string
32
	 */
33
34
	public function getPattern() : string
35
	{
36
		return $this->_pattern;
37
	}
38
39
	/**
40
	 * validate the user
41
	 *
42
	 * @since 4.3.0
43
	 *
44
	 * @param string $name name to be validated
45
	 *
46
	 * @return bool
47
	 */
48
49
	public function validate(string $name = null) : bool
50
	{
51
		return preg_match('/' . $this->_pattern . '/', $name);
52
	}
53
}
54