Passed
Pull Request — master (#164)
by Christoffer
02:18
created

DefinitionBuilderCreator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 10 1
1
<?php
2
3
namespace Digia\GraphQL\Schema;
4
5
use Psr\SimpleCache\CacheInterface;
6
7
class DefinitionBuilderCreator implements DefinitionBuilderCreatorInterface
8
{
9
    /**
10
     * @var CacheInterface
11
     */
12
    protected $cache;
13
14
    /**
15
     * DefinitionBuilderCreator constructor.
16
     */
17
    public function __construct(CacheInterface $cache)
18
    {
19
        $this->cache = $cache;
20
    }
21
22
    /**
23
     * @inheritdoc
24
     * @throws \Psr\SimpleCache\InvalidArgumentException
25
     */
26
    public function create(
27
        array $typeDefinitionsMap,
28
        ?callable $resolveTypeFunction = null,
29
        ?ResolverRegistryInterface $resolverRegistry = null
30
    ): DefinitionBuilderInterface {
31
        return new DefinitionBuilder(
32
            $typeDefinitionsMap,
33
            $resolverRegistry ?? new ResolverMapRegistry(),
34
            $resolveTypeFunction,
35
            $this->cache
36
        );
37
    }
38
}
39