Code Duplication    Length = 30-30 lines in 4 locations

src/Validators/AlphaDash.php 1 location

@@ 12-41 (lines=30) @@
9
 *
10
 * @since 0.11.0
11
 */
12
class AlphaDash extends AbstractValidator {
13
14
	/**
15
	 *
16
	 *
17
	 * @since 0.11.0
18
	 * @access protected
19
	 * @var array
20
	 */
21
	protected $template = [
22
		'message' => '{label} can only contain alphabetic characters, dashes, and underscores',
23
		'name' => 'alpha',
24
	];
25
26
	/**
27
	 * Set the validation constraints that make this rule
28
	 *
29
	 * @since 0.11.0
30
	 *
31
	 * @param bool (optional) $optional
32
	 * @return self
33
	 */
34
	public function set_policy( $optional = false ) {
35
		$v = $this->validator;
36
		$v = ( $optional )
37
			? $v->optional( $v->create()->alpha('-_') )
38
			: $v->alpha('-_');
39
		return $this;
40
	}
41
}
42

src/Validators/Digit.php 1 location

@@ 12-41 (lines=30) @@
9
 *
10
 * @since 0.11.0
11
 */
12
class Digit extends AbstractValidator {
13
14
	/**
15
	 *
16
	 *
17
	 * @since 0.11.0
18
	 * @access protected
19
	 * @var array
20
	 */
21
	protected $template = [
22
		'message' => '{label} must be a digit',
23
		'name' => 'digit',
24
	];
25
26
	/**
27
	 * Set the validation constraints that make this rule
28
	 *
29
	 * @since 0.11.0
30
	 *
31
	 * @param bool (optional) $optional
32
	 * @return self
33
	 */
34
	public function set_policy( $optional = false ) {
35
		$v = $this->validator;
36
		$v = ( $optional )
37
			? $v->optional( $v->create()->digit()->length(1,1) )
38
			: $v->digit()->length(1,1);
39
		return $this;
40
	}
41
}
42

src/Validators/AlphaNum.php 1 location

@@ 12-41 (lines=30) @@
9
 *
10
 * @since 0.11.0
11
 */
12
class AlphaNum extends AbstractValidator {
13
14
	/**
15
	 *
16
	 *
17
	 * @since 0.11.0
18
	 * @access protected
19
	 * @var array
20
	 */
21
	protected $template = [
22
		'message' => '{label} can only contain alpha-numeric characters',
23
		'name' => 'alpha_num',
24
	];
25
26
	/**
27
	 * Set the validation constraints that make this rule
28
	 *
29
	 * @since 0.11.0
30
	 *
31
	 * @param bool (optional) $optional
32
	 * @return self
33
	 */
34
	public function set_policy( $optional = false ) {
35
		$v = $this->validator;
36
		$v = ( $optional )
37
			? $v->optional( $v->create()->alnum() )
38
			: $v->alnum();
39
		return $this;
40
	}
41
}
42

src/Validators/Integer.php 1 location

@@ 12-41 (lines=30) @@
9
 *
10
 * @since 0.11.0
11
 */
12
class Integer extends AbstractValidator {
13
14
	/**
15
	 *
16
	 *
17
	 * @since 0.11.0
18
	 * @access protected
19
	 * @var array
20
	 */
21
	protected $template = [
22
		'message' => '{label} must be an integer',
23
		'name' => 'integer',
24
	];
25
26
	/**
27
	 * Set the validation constraints that make this rule
28
	 *
29
	 * @since 0.11.0
30
	 *
31
	 * @param bool (optional) $optional
32
	 * @return self
33
	 */
34
	public function set_policy( $optional = false ) {
35
		$v = $this->validator;
36
		$v = ( $optional )
37
			? $v->optional( $v->create()->intVal() )
38
			: $v->intVal();
39
		return $this;
40
	}
41
}
42