Completed
Pull Request — master (#47)
by David
01:40
created

ControllerQueryProviderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
dl 0
loc 49
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildQueryProvider() 0 10 1
A __construct() 0 9 1
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers;
5
6
7
use Psr\Container\ContainerInterface;
8
use TheCodingMachine\GraphQL\Controllers\Mappers\RecursiveTypeMapperInterface;
9
use TheCodingMachine\GraphQL\Controllers\Security\AuthenticationServiceInterface;
10
use TheCodingMachine\GraphQL\Controllers\Security\AuthorizationServiceInterface;
11
12
class ControllerQueryProviderFactory
13
{
14
    /**
15
     * @var AnnotationReader
16
     */
17
    private $annotationReader;
18
    /**
19
     * @var HydratorInterface
20
     */
21
    private $hydrator;
22
    /**
23
     * @var AuthenticationServiceInterface
24
     */
25
    private $authenticationService;
26
    /**
27
     * @var AuthorizationServiceInterface
28
     */
29
    private $authorizationService;
30
    /**
31
     * @var ContainerInterface
32
     */
33
    private $registry;
34
35
    public function __construct(AnnotationReader $annotationReader,
36
                                HydratorInterface $hydrator, AuthenticationServiceInterface $authenticationService,
37
                                AuthorizationServiceInterface $authorizationService, ContainerInterface $registry)
38
    {
39
        $this->annotationReader = $annotationReader;
40
        $this->hydrator = $hydrator;
41
        $this->authenticationService = $authenticationService;
42
        $this->authorizationService = $authorizationService;
43
        $this->registry = $registry;
44
    }
45
46
    /**
47
     * @param object $controller
48
     * @param RecursiveTypeMapperInterface $typeMapper
49
     * @return ControllerQueryProvider
50
     */
51
    public function buildQueryProvider($controller, RecursiveTypeMapperInterface $typeMapper): ControllerQueryProvider
52
    {
53
        return new ControllerQueryProvider(
54
            $controller,
55
            $this->annotationReader,
56
            $typeMapper,
57
            $this->hydrator,
58
            $this->authenticationService,
59
            $this->authorizationService,
60
            $this->registry
61
        );
62
    }
63
}
64