Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Validator;
6
 
7
use Laminas\Validator\AbstractValidator;
8
use Laminas\Validator\GreaterThan;
9
use Laminas\Stdlib\ArrayUtils;
10
use Traversable;
11
 
12
 
13
class GreaterThanOtherField extends GreaterThan
14
{
15
    /**
16
     *
17
     * @var string
18
     */
19
    protected $token;
20
 
21
    /**
22
     *
23
     * @var bool
24
     */
25
    protected $inclusive;
26
 
27
    public function __construct($options = null)
28
    {
29
 
30
        if (! array_key_exists('token', $options)) {
31
            throw new \InvalidArgumentException("Missing option 'token'");
32
        }
33
 
34
        $this->token        =  $options['token'];
35
        $options = [
36
            'min' => 0,
37
            'inclusive' => false,
38
        ];
39
 
40
        parent::__construct($options);
41
    }
42
 
43
    public function isValid($value, $context = null)
44
    {
45
        $min = isset($context[$this->token]) ? $context[$this->token] : 0;
46
        $this->setMin($min);
47
 
48
 
49
        return parent::isValid($value);
50
 
51
    }
52
}