1: <?php
2:
3: /**
4: * Jyxo PHP Library
5: *
6: * LICENSE
7: *
8: * This source file is subject to the new BSD license that is bundled
9: * with this package in the file license.txt.
10: * It is also available through the world-wide-web at this URL:
11: * https://github.com/jyxo/php/blob/master/license.txt
12: */
13:
14: namespace Jyxo\Input\Validator;
15:
16: /**
17: * Validates a value.
18: *
19: * @category Jyxo
20: * @package Jyxo\Input
21: * @subpackage Validator
22: * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
23: * @license https://github.com/jyxo/php/blob/master/license.txt
24: * @author Jaroslav HanslĂk
25: */
26: class Equals extends \Jyxo\Input\Validator\AbstractValidator
27: {
28:
29: /**
30: * Expected value.
31: *
32: * @var mixed
33: */
34: protected $expected;
35:
36:
37: /**
38: * Constructor.
39: *
40: * @param mixed $expected Expected value
41: */
42: public function __construct($expected)
43: {
44: $this->setExpected($expected);
45: }
46:
47: /**
48: * Sets the expected value.
49: *
50: * @param mixed $expected Expected value
51: * @return \Jyxo\Input\Validator\Equals
52: */
53: public function setExpected($expected)
54: {
55: $this->expected = $expected;
56:
57: return $this;
58: }
59:
60: /**
61: * Returns the expected value.
62: *
63: * @return mixed
64: */
65: public function getExpected()
66: {
67: return $this->expected;
68: }
69:
70: /**
71: * Validates a value.
72: *
73: * @param mixed $value Input value
74: * @return boolean
75: */
76: public function isValid($value)
77: {
78: return $value == $this->expected;
79: }
80:
81: }
82: