ComparerNotFullValidator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Locastic\SyliusComparerPlugin\Validator\Constraints;
6
7
use Locastic\SyliusComparerPlugin\Utils\ComparerCapacityCheckerInterface;
8
use Symfony\Component\Validator\Constraint;
9
use Symfony\Component\Validator\ConstraintValidator;
10
11
class ComparerNotFullValidator extends ConstraintValidator
12
{
13
    /** @var ComparerCapacityCheckerInterface */
14
    private $capacityChecker;
15
16
    public function __construct(ComparerCapacityCheckerInterface $capacityChecker)
17
    {
18
        $this->capacityChecker = $capacityChecker;
19
    }
20
21
    public function validate($comparer, Constraint $constraint)
22
    {
23
        if ($this->capacityChecker->isComparerFilled($comparer)) {
24
            $this->context
25
                ->buildViolation($constraint->message)
26
                ->atPath('comparerFullMessage')
27
                ->addViolation();
28
        }
29
    }
30
}
31