Completed
Push — master ( 2975e7...46c3ee )
by Rafael
07:49
created

QueryExecutionContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 52
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getEndpoint() 0 3 1
A getDefinition() 0 3 1
A getQueryId() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Resolver;
12
13
use Ynlo\GraphQLBundle\Definition\ExecutableDefinitionInterface;
14
use Ynlo\GraphQLBundle\Definition\QueryDefinition;
15
use Ynlo\GraphQLBundle\Definition\Registry\Endpoint;
16
17
/**
18
 * Context where a main query is executed
19
 */
20
class QueryExecutionContext
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $queryId;
26
27
    /**
28
     * @var Endpoint
29
     */
30
    protected $endpoint;
31
32
    /**
33
     * @var ExecutableDefinitionInterface
34
     */
35
    protected $definition;
36
37
    /**
38
     * QueryExecutionContext constructor.
39
     *
40
     * @param Endpoint                      $endpoint
41
     * @param ExecutableDefinitionInterface $definition
42
     */
43 3
    public function __construct(Endpoint $endpoint, ExecutableDefinitionInterface $definition = null)
44
    {
45 3
        $this->queryId = md5(time().mt_rand().spl_object_hash($this));
46 3
        $this->endpoint = $endpoint;
47 3
        $this->definition = $definition ?? new QueryDefinition();
48 3
    }
49
50
    /**
51
     * @return string
52
     */
53 2
    public function getQueryId(): string
54
    {
55 2
        return $this->queryId;
56
    }
57
58
    /**
59
     * @return Endpoint
60
     */
61 1
    public function getEndpoint(): Endpoint
62
    {
63 1
        return $this->endpoint;
64
    }
65
66
    /**
67
     * @return ExecutableDefinitionInterface
68
     */
69
    public function getDefinition(): ExecutableDefinitionInterface
70
    {
71
        return $this->definition;
72
    }
73
}
74