Completed
Pull Request — 1.x (#9)
by Dorian
44:57 queued 43:25
created

GreaterThanValidator::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 6
loc 6
rs 9.4285
cc 3
eloc 3
nc 2
nop 2
1
<?php
2
namespace MetaHydrator\Validator;
3
4
use MetaHydrator\Exception\ValidationException;
5
6 View Code Duplication
class GreaterThanValidator extends AbstractValidator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
{
8
    /** @var mixed */
9
    protected $min;
10
11
    public function __construct($min, $errorMessage = "")
12
    {
13
        parent::__construct($errorMessage);
14
        $this->min = $min;
15
    }
16
17
    /**
18
     * @param mixed $value
19
     * @param $contextObject
20
     *
21
     * @throws ValidationException
22
     */
23
    public function validate($value, $contextObject = null)
24
    {
25
        if ($value !== null && $value < $this->min) {
26
            $this->throw();
27
        }
28
    }
29
}
30