Test Setup Failed
Push — master ( 1595cb...050b68 )
by Kirill
21:00
created

ValidatorFacadeTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assertValid() 0 3 1
A getValidator() 0 3 1
A bootValidatorFacadeTrait() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Compiler;
13
14
use GraphQL\Contracts\TypeSystem\DefinitionInterface;
15
use Railt\SDL\Validator\Factory;
16
use Railt\SDL\Validator\ValidatorInterface;
17
18
/**
19
 * Trait ValidatorFacadeTrait
20
 */
21
trait ValidatorFacadeTrait
22
{
23
    /**
24
     * @var ValidatorInterface
25
     */
26
    protected ValidatorInterface $validator;
27
28
    /**
29
     * @return void
30
     */
31
    private function bootValidatorFacadeTrait(): void
32
    {
33
        $this->validator = new Factory();
34
    }
35
36
    /**
37
     * @return ValidatorInterface
38
     */
39
    public function getValidator(): ValidatorInterface
40
    {
41
        return $this->validator;
42
    }
43
44
    /**
45
     * @param DefinitionInterface $definition
46
     * @return void
47
     */
48
    public function assertValid(DefinitionInterface $definition): void
49
    {
50
        $this->validator->assert($definition);
51
    }
52
}
53