Completed
Pull Request — master (#159)
by Christoffer
02:45
created

SchemaValidationProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
1
<?php
2
3
namespace Digia\GraphQL\SchemaValidation;
4
5
use Digia\GraphQL\SchemaValidation\Rule\DirectivesRule;
6
use Digia\GraphQL\SchemaValidation\Rule\RootTypesRule;
7
use Digia\GraphQL\SchemaValidation\Rule\TypesRule;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
10
class SchemaValidationProvider extends AbstractServiceProvider
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $provides = [
16
        ValidationContextCreatorInterface::class,
17
        SchemaValidatorInterface::class,
18
        RootTypesRule::class,
19
        DirectivesRule::class,
20
        TypesRule::class,
21
    ];
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function register()
27
    {
28
        $this->container->add(ValidationContextCreatorInterface::class, ValidationContextCreator::class,
29
            true/* $shared */);
30
        $this->container->add(SchemaValidatorInterface::class, SchemaValidator::class, true/* $shared */)
31
            ->withArgument(ValidationContextCreatorInterface::class);
32
33
        // Rules
34
        $this->container->add(RootTypesRule::class, RootTypesRule::class);
35
        $this->container->add(DirectivesRule::class, DirectivesRule::class);
36
        $this->container->add(TypesRule::class, TypesRule::class);
37
    }
38
}
39