Completed
Branch master (85eed3)
by
unknown
02:32
created

Parameters::getPaginationParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Neomerx\JsonApi\Http\Parameters;
2
3
/**
4
 * Copyright 2015 [email protected] (www.neomerx.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use \Neomerx\JsonApi\Contracts\Http\Headers\HeaderInterface;
20
use \Neomerx\JsonApi\Contracts\Http\Headers\AcceptHeaderInterface;
21
use \Neomerx\JsonApi\Contracts\Http\Parameters\ParametersInterface;
22
use \Neomerx\JsonApi\Contracts\Http\Parameters\SortParameterInterface;
23
24
/**
25
 * @package Neomerx\JsonApi
26
 */
27
class Parameters extends EncodingParameters implements ParametersInterface
28
{
29
    /**
30
     * @var HeaderInterface
31
     */
32
    private $contentType;
33
34
    /**
35
     * @var AcceptHeaderInterface
36
     */
37
    private $accept;
38
39
    /**
40
     * @var SortParameterInterface[]|null
41
     */
42
    private $sortParameters;
43
44
    /**
45
     * @var array|null
46
     */
47
    private $pagingParameters;
48
49
    /**
50
     * @var array|null
51
     */
52
    private $filteringParameters;
53
54
    /**
55
     * @var array|null
56
     */
57
    private $unrecognizedParams;
58
59
    /**
60
     * @param HeaderInterface               $contentType
61
     * @param AcceptHeaderInterface         $accept
62
     * @param string[]|null                 $includePaths
63
     * @param array|null                    $fieldSets
64
     * @param SortParameterInterface[]|null $sortParameters
65
     * @param array|null                    $pagingParameters
66
     * @param array|null                    $filteringParameters
67
     * @param array|null                    $unrecognizedParams
68
     */
69 25
    public function __construct(
70
        HeaderInterface $contentType,
71
        AcceptHeaderInterface $accept,
72
        $includePaths = null,
73
        array $fieldSets = null,
74
        $sortParameters = null,
75
        array $pagingParameters = null,
76
        array $filteringParameters = null,
77
        array $unrecognizedParams = null
78
    ) {
79 25
        parent::__construct($includePaths, $fieldSets);
80
81 25
        $this->contentType         = $contentType;
82 25
        $this->accept              = $accept;
83 25
        $this->sortParameters      = $sortParameters;
84 25
        $this->pagingParameters    = $pagingParameters;
85 25
        $this->unrecognizedParams  = $unrecognizedParams;
86 25
        $this->filteringParameters = $filteringParameters;
87 25
    }
88
89
    /**
90
     * @inheritdoc
91
     */
92 19
    public function getContentTypeHeader()
93
    {
94 19
        return $this->contentType;
95
    }
96
97
    /**
98
     * @inheritdoc
99
     */
100 21
    public function getAcceptHeader()
101
    {
102 21
        return $this->accept;
103
    }
104
105
    /**
106
     * @inheritdoc
107
     */
108 13
    public function getSortParameters()
109
    {
110 13
        return $this->sortParameters;
111
    }
112
113
    /**
114
     * @inheritdoc
115
     */
116 12
    public function getPaginationParameters()
117
    {
118 12
        return $this->pagingParameters;
119
    }
120
121
    /**
122
     * @inheritdoc
123
     */
124 13
    public function getFilteringParameters()
125
    {
126 13
        return $this->filteringParameters;
127
    }
128
129
    /**
130
     * @inheritdoc
131
     */
132 9
    public function getUnrecognizedParameters()
133
    {
134 9
        return $this->unrecognizedParams;
135
    }
136
137
    /**
138
     * @inheritdoc
139
     */
140 2
    public function isEmpty()
141
    {
142
        return
143 2
            empty($this->getFieldSets()) === true && empty($this->getIncludePaths()) === true &&
144 2
            empty($this->getSortParameters()) === true && empty($this->getPaginationParameters()) === true &&
145 2
            empty($this->getFilteringParameters()) === true;
146
    }
147
}
148