ResponseCollection::getCount()   A
last analyzed

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 graze/gigya-client
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/gigya-client/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/gigya-client
12
 */
13
14
namespace Graze\Gigya\Response;
15
16
use Illuminate\Support\Collection;
17
use Psr\Http\Message\ResponseInterface as GuzzleResponseInterface;
18
19
class ResponseCollection extends Response implements ResponseCollectionInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    protected $count;
25
26
    /**
27
     * @var int
28
     */
29
    protected $total;
30
31
    /**
32
     * @var string
33
     */
34
    protected $nextCursor;
35
36
    /**
37
     * @var array
38
     */
39
    protected $results;
40
41
    /**
42
     * ResponseCollection constructor.
43
     *
44
     * @param GuzzleResponseInterface $response
45
     */
46 1
    public function __construct(GuzzleResponseInterface $response)
47
    {
48 1
        parent::__construct($response);
49 1
        $this->count = (int) $this->popField('objectsCount');
50 1
        $this->total = (int) $this->popField('totalCount');
51 1
        $this->nextCursor = $this->popField('nextCursorId');
52 1
        $this->results = (array) $this->popField('results');
53 1
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 1
    public function getData()
59
    {
60 1
        return new Collection($this->results);
61
    }
62
63
    /**
64
     * @return int
65
     */
66 1
    public function getCount()
67
    {
68 1
        return $this->count;
69
    }
70
71
    /**
72
     * @return int
73
     */
74 1
    public function getTotal()
75
    {
76 1
        return $this->total;
77
    }
78
79
    /**
80
     * The cursor for the next set of results, if this is null there are no more results.
81
     *
82
     * @return string|null
83
     */
84 1
    public function getNextCursor()
85
    {
86 1
        return $this->nextCursor;
87
    }
88
}
89