Completed
Push — master ( f446c4...139ced )
by Craig
05:23
created

ValidControllerValidator::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula Foundation - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\SettingsModule\Validator\Constraints;
15
16
17
use Symfony\Component\Validator\Constraint;
18
use Symfony\Component\Validator\ConstraintValidator;
19
20
class ValidControllerValidator extends ConstraintValidator
21
{
22
    public function validate($value, Constraint $constraint)
23
    {
24
        [$fqcn, $method] = explode('::', $value);
25
        if (!class_exists($fqcn) || !is_callable([$fqcn, $method])) {
26
            $this->context->buildViolation($constraint->message)
27
                ->addViolation();
28
        }
29
    }
30
}