Collection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 1
dl 0
loc 91
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPaginator() 0 4 1
A hasPaginator() 0 4 1
A getCursor() 0 4 1
A hasCursor() 0 4 1
A setPaginator() 0 6 1
A setCursor() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the League\Fractal package.
5
 *
6
 * (c) Phil Sturgeon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Fractal\Resource;
13
14
use ArrayIterator;
15
use League\Fractal\Pagination\CursorInterface;
16
use League\Fractal\Pagination\PaginatorInterface;
17
18
/**
19
 * Resource Collection
20
 *
21
 * The data can be a collection of any sort of data, as long as the
22
 * "collection" is either array or an object implementing ArrayIterator.
23
 */
24
class Collection extends ResourceAbstract
25
{
26
    /**
27
     * A collection of data.
28
     *
29
     * @var array|ArrayIterator
30
     */
31
    protected $data;
32
33
    /**
34
     * The paginator instance.
35
     *
36
     * @var PaginatorInterface
37
     */
38
    protected $paginator;
39
40
    /**
41
     * The cursor instance.
42
     *
43
     * @var CursorInterface
44
     */
45
    protected $cursor;
46
47
    /**
48
     * Get the paginator instance.
49
     *
50
     * @return PaginatorInterface
51
     */
52 5
    public function getPaginator()
53
    {
54 5
        return $this->paginator;
55
    }
56
57
    /**
58
     * Determine if the resource has a paginator implementation.
59
     *
60
     * @return bool
61
     */
62 30
    public function hasPaginator()
63
    {
64 30
        return $this->paginator instanceof PaginatorInterface;
65
    }
66
67
    /**
68
     * Get the cursor instance.
69
     *
70
     * @return CursorInterface
71
     */
72 2
    public function getCursor()
73
    {
74 2
        return $this->cursor;
75
    }
76
77
    /**
78
     * Determine if the resource has a cursor implementation.
79
     *
80
     * @return bool
81
     */
82 31
    public function hasCursor()
83
    {
84 31
        return $this->cursor instanceof CursorInterface;
85
    }
86
87
    /**
88
     * Set the paginator instance.
89
     *
90
     * @param PaginatorInterface $paginator
91
     *
92
     * @return $this
93
     */
94 5
    public function setPaginator(PaginatorInterface $paginator)
95
    {
96 5
        $this->paginator = $paginator;
97
98 5
        return $this;
99
    }
100
101
    /**
102
     * Set the cursor instance.
103
     *
104
     * @param CursorInterface $cursor
105
     *
106
     * @return $this
107
     */
108 2
    public function setCursor(CursorInterface $cursor)
109
    {
110 2
        $this->cursor = $cursor;
111
112 2
        return $this;
113
    }
114
}
115