ZoneNameValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 10 4
1
<?php
2
3
/*
4
 * This file is part of the CwdPowerDNS Client
5
 *
6
 * (c) 2018 cwd.at GmbH <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cwd\PowerDNSClient\Validator;
15
16
use Symfony\Component\Validator\Constraint;
17
use Symfony\Component\Validator\ConstraintValidator;
18
19
class ZoneNameValidator extends ConstraintValidator
20
{
21
    public function validate($value, Constraint $constraint): void
22
    {
23
        if (null === $value || '' === $value) {
24
            return;
25
        }
26
27
        if ('.' !== substr($value, -1)) {
28
            $this->context->buildViolation($constraint->message)
29
                ->setParameter('{{ string }}', $value)
30
                ->addViolation();
31
        }
32
    }
33
}
34