1: <?php
2:
3: /**
4: * Pry Framework
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: *
11: */
12:
13: namespace Pry\Validate\Validator;
14:
15: use Pry\Validate\ValidateAbstract;
16:
17: /**
18: * Validateur d'égalité
19: * @category Pry
20: * @package Validate
21: * @subpackage Validate_Validator
22: * @version 1.0.0
23: * @author Olivier ROGER <oroger.fr>
24: *
25: * <code>
26: * $validator = new Validate_Validator_Equal(45);
27: * $validator -> isValid(12); // retourne false
28: * $validator -> isValid(45); // retourne true
29: * </code>
30: */
31: class Equal extends ValidateAbstract
32: {
33:
34: private $reference;
35:
36: /**
37: * Constructeur
38: *
39: */
40: public function __construct($ref)
41: {
42: $this->reference = $ref;
43: $this->errorMsg = "n'est pas égale à $this->reference";
44: }
45:
46: /**
47: * Vérifie l'égalité des deux valeurs
48: *
49: * @param mixed $string Element à valider
50: * @return boolean
51: */
52: public function isValid($string)
53: {
54: if ($this->reference == $string)
55: return true;
56: return false;
57: }
58:
59: }