Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractValidator
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMessage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInput
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setValue
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setMessage
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setInput
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 evaluate
n/a
0 / 0
n/a
0 / 0
0
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Validator;
15
16/**
17 * Validator class
18 *
19 * @category   Pop
20 * @package    Pop\Validator
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    3.2.0
25 */
26abstract class AbstractValidator implements ValidatorInterface
27{
28
29    /**
30     * Validator value to test against
31     * @var mixed
32     */
33    protected $value = null;
34
35    /**
36     * Input value to test
37     * @var mixed
38     */
39    protected $input = null;
40
41    /**
42     * Validator message
43     * @var string
44     */
45    protected $message = null;
46
47    /**
48     * Constructor
49     *
50     * Instantiate the validator object
51     *
52     * @param  mixed  $value
53     * @param  string $message
54     */
55    public function __construct($value = null, $message = null)
56    {
57        $this->setValue($value);
58        if (null !== $message) {
59            $this->setMessage($message);
60        }
61    }
62
63    /**
64     * Get the validator value
65     *
66     * @return mixed
67     */
68    public function getValue()
69    {
70        return $this->value;
71    }
72
73    /**
74     * Get the validator default message
75     *
76     * @return boolean
77     */
78    public function getMessage()
79    {
80        return $this->message;
81    }
82
83    /**
84     * GEt the validator input
85     *
86     * @return mixed
87     */
88    public function getInput()
89    {
90        return $this->input;
91    }
92
93    /**
94     * Set the validator value
95     *
96     * @param  mixed $value
97     * @return AbstractValidator
98     */
99    public function setValue($value)
100    {
101        $this->value = $value;
102        return $this;
103    }
104
105    /**
106     * Set the validator condition
107     *
108     * @param  string $msg
109     * @return AbstractValidator
110     */
111    public function setMessage($msg = null)
112    {
113        $this->message = $msg;
114        return $this;
115    }
116
117    /**
118     * Set the validator input
119     *
120     * @param  mixed $input
121     * @return AbstractValidator
122     */
123    public function setInput($input = null)
124    {
125        $this->input = $input;
126        return $this;
127    }
128
129    /**
130     * Evaluate
131
132     * @param  mixed $input
133     * @return boolean
134     */
135    abstract public function evaluate($input = null);
136
137}