Completed
Push — master ( df309f...9e12f0 )
by Rafael
08:32
created

NodeConnection::getEdges()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\Model;
12
13
use Ynlo\GraphQLBundle\Annotation as GraphQL;
14
15
/**
16
 * @GraphQL\ObjectType()
17
 */
18
class NodeConnection implements ConnectionInterface
19
{
20
    /**
21
     * @var int
22
     *
23
     * @GraphQL\Field(type="Int!")
24
     */
25
    protected $totalCount = 0;
26
27
    /**
28
     * @var array
29
     *
30
     * @GraphQL\Field(type="[Ynlo\GraphQLBundle\Model\EdgeInterface]")
31
     */
32
    protected $edges = [];
33
34
    /**
35
     * @var PageInfo
36
     *
37
     * @GraphQL\Field(type="Ynlo\GraphQLBundle\Model\PageInfo!")
38
     */
39
    protected $pageInfo;
40
41
    /**
42
     * NodeConnection constructor.
43
     */
44 6
    public function __construct()
45
    {
46 6
        $this->pageInfo = new PageInfo();
47 6
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 6
    public function getTotalCount(): int
53
    {
54 6
        return $this->totalCount;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 6
    public function setTotalCount(int $totalCount)
61
    {
62 6
        $this->totalCount = $totalCount;
63 6
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68 6
    public function addEdge(EdgeInterface $edge)
69
    {
70 6
        $this->edges[] = $edge;
71 6
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 6
    public function createEdge(NodeInterface $node, string $cursor)
77
    {
78 6
        return new NodeConnectionEdge($node, $cursor);
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84 6
    public function getEdges(): array
85
    {
86 6
        return $this->edges;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function setEdges(array $edges)
93
    {
94
        $this->edges = $edges;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100 6
    public function getPageInfo(): PageInfo
101
    {
102 6
        return $this->pageInfo;
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function setPageInfo(PageInfo $pageInfo)
109
    {
110
        $this->pageInfo = $pageInfo;
111
    }
112
}
113