Passed
Push — develop ( 78626b...5e19ee )
by Daniel
05:26
created

LinkValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A validate() 0 7 2
1
<?php
2
3
namespace Silverback\ApiComponentBundle\Validator\Constraints;
4
5
use Silverback\ApiComponentBundle\Repository\RouteRepository;
6
use Symfony\Component\Validator\Constraint;
7
use Symfony\Component\Validator\Constraints\UrlValidator;
8
9
/**
10
 * @author Daniel West <[email protected]>
11
 * @Annotation()
12
 */
13
class LinkValidator extends UrlValidator
14
{
15
    /** @var RouteRepository  */
16
    private $routeRepository;
17
18
    public function __construct (
19
        RouteRepository $routeRepository
20
    )
21
    {
22
        $this->routeRepository = $routeRepository;
23
    }
24
25
    public function validate($value, Constraint $constraint)
26
    {
27
        $route = $this->routeRepository->find($value);
28
        if ($route) {
29
            return;
30
        }
31
        parent::validate($value, $constraint);
32
    }
33
}
34