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

ValidControllerValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 6 3
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
}