Completed
Push — master ( 540370...4c31d8 )
by Rafael
06:09
created

NodeConnection::setPageInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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 int
29
     *
30
     * @GraphQL\Field(type="Int!")
31
     */
32
    protected $pages = 0;
33
34
    /**
35
     * @var array
36
     *
37
     * @GraphQL\Field(type="[Ynlo\GraphQLBundle\Model\EdgeInterface]")
38
     */
39
    protected $edges = [];
40
41
    /**
42
     * @var PageInfo
43
     *
44
     * @GraphQL\Field(type="Ynlo\GraphQLBundle\Model\PageInfo!")
45
     */
46
    protected $pageInfo;
47
48
    /**
49
     * NodeConnection constructor.
50
     */
51 6
    public function __construct()
52
    {
53 6
        $this->pageInfo = new PageInfo();
54 6
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 6
    public function getTotalCount(): int
60
    {
61 6
        return $this->totalCount;
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67 6
    public function setTotalCount(int $totalCount)
68
    {
69 6
        $this->totalCount = $totalCount;
70 6
    }
71
72
    /**
73
     * @return int
74
     */
75
    public function getPages(): int
76
    {
77
        return $this->pages;
78
    }
79
80
    /**
81
     * @param int $pages
82
     *
83
     * @return NodeConnection
84
     */
85 6
    public function setPages(int $pages): ConnectionInterface
86
    {
87 6
        $this->pages = $pages;
88
89 6
        return $this;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 6
    public function addEdge(EdgeInterface $edge)
96
    {
97 6
        $this->edges[] = $edge;
98 6
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 6
    public function createEdge(NodeInterface $node, string $cursor)
104
    {
105 6
        return new NodeConnectionEdge($node, $cursor);
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111 6
    public function getEdges(): array
112
    {
113 6
        return $this->edges;
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function setEdges(array $edges)
120
    {
121
        $this->edges = $edges;
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127 6
    public function getPageInfo(): PageInfo
128
    {
129 6
        return $this->pageInfo;
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135
    public function setPageInfo(PageInfo $pageInfo)
136
    {
137
        $this->pageInfo = $pageInfo;
138
    }
139
}
140