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

LinkValidator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 2
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
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