Proyectos de Subversion LeadersLinked - Backend

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
use Laminas\Validator\LessThan;
12
 
13
 
14
class LessThanOtherField extends LessThan
15
{
16
    /**
17
     *
18
     * @var string
19
     */
20
    protected $token;
21
 
22
    /**
23
     *
24
     * @var bool
25
     */
26
    protected $inclusive;
27
 
28
    public function __construct($options = null)
29
    {
30
 
31
        if (! array_key_exists('token', $options)) {
32
            throw new \InvalidArgumentException("Missing option 'token'");
33
        }
34
 
35
        $this->token        =  $options['token'];
36
        $options = [
37
            'max' => 0,
38
            'inclusive' => false,
39
        ];
40
 
41
        parent::__construct($options);
42
    }
43
 
44
    public function isValid($value, $context = null)
45
    {
46
        $max = isset($context[$this->token]) ? $context[$this->token] : 0;
47
        $this->setMax($max);
48
 
49
 
50
        return parent::isValid($value);
51
 
52
    }
53
}