GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5f1784...eb0b53 )
by Jan
02:19
created

Search::getCondition()   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 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * Copyright 2013 Jan Eichhorn <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace ApaiIO\Operations;
19
20
/**
21
 * A item search operation
22
 *
23
 * @see    http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/ItemSearch.html
24
 * @author Jan Eichhorn <[email protected]>
25
 */
26
class Search extends AbstractOperation
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31 8
    public function getName()
32
    {
33 8
        return 'ItemSearch';
34
    }
35
36
    /**
37
     * Return the amazon category
38
     *
39
     * @return string
40
     */
41 1
    public function getCategory()
42
    {
43 1
        return $this->getSingleOperationParameter('SearchIndex');
44
    }
45
46
    /**
47
     * Sets the amazon category
48
     *
49
     * @param string $category
50
     *
51
     * @return \ApaiIO\Operations\Search
52
     */
53 8
    public function setCategory($category)
54
    {
55 8
        $this->parameter['SearchIndex'] = $category;
56
57 8
        return $this;
58
    }
59
60
    /**
61
     * Returns the keywords
62
     *
63
     * @return string
64
     */
65 1
    public function getKeywords()
66
    {
67 1
        return $this->getSingleOperationParameter('Keywords');
68
    }
69
70
    /**
71
     * Sets the keywords
72
     *
73
     * @param string $keywords
74
     *
75
     * @return \ApaiIO\Operations\Search
76
     */
77 5
    public function setKeywords($keywords)
78
    {
79 5
        $this->parameter['Keywords'] = $keywords;
80
81 5
        return $this;
82
    }
83
84
    /**
85
     * Return the resultpage
86
     *
87
     * @return integer
88
     */
89 1
    public function getPage()
90
    {
91 1
        return $this->getSingleOperationParameter('ItemPage');
92
    }
93
94
    /**
95
     * Sets the resultpage to a specified value
96
     * Allows to browse resultsets which have more than one page
97
     *
98
     * @param integer $page
99
     *
100
     * @return \ApaiIO\Operations\Search
101
     */
102 10
    public function setPage($page)
103
    {
104 10 View Code Duplication
        if (false === is_numeric($page) || $page < 1 || $page > 10) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105 1
            throw new \InvalidArgumentException(sprintf('%s is an invalid page value. It has to be numeric, positive and between 1 and 10',
106 1
                    $page));
107
        }
108
109 9
        $this->parameter['ItemPage'] = $page;
110
111 9
        return $this;
112
    }
113
114
    /**
115
     * Return the minimum price as integer so 8.99$ will be returned as 899
116
     *
117
     * @return integer
118
     */
119 2
    public function getMinimumPrice()
120
    {
121 2
        return $this->getSingleOperationParameter('MinimumPrice');
122
    }
123
124
    /**
125
     * Sets the minimum price to a specified value for the search
126
     * Currency will be given by the site you are querying: EUR for IT, USD for COM
127
     * Price should be given as integer. 8.99$ USD becomes 899
128
     *
129
     * @param integer $price
130
     *
131
     * @return \ApaiIO\Operations\Search
132
     */
133 3
    public function setMinimumPrice($price)
134
    {
135 3
        $this->validatePrice($price);
136 2
        $this->parameter['MinimumPrice'] = $price;
137
138 2
        return $this;
139
    }
140
141
    /**
142
     * Returns the maximum price as integer so 8.99$ will be returned as 899
143
     * @return mixed
144
     */
145 2
    public function getMaximumPrice()
146
    {
147 2
        return $this->getSingleOperationParameter('MaximumPrice');
148
    }
149
150
    /**
151
     * Sets the maximum price to a specified value for the search
152
     * Currency will be given by the site you are querying: EUR for IT, USD for COM
153
     * Price should be given as integer. 8.99$ USD becomes 899
154
     *
155
     * @param integer $price
156
     *
157
     * @return \ApaiIO\Operations\Search
158
     */
159 3
    public function setMaximumPrice($price)
160
    {
161 3
        $this->validatePrice($price);
162 2
        $this->parameter['MaximumPrice'] = $price;
163
164 2
        return $this;
165
    }
166
167
    /**
168
     * Returns the condition of the items to return. New | Used | Collectible | Refurbished | All
169
     *
170
     * @return string
171
     */
172 2
    public function getCondition()
173
    {
174 2
        return $this->getSingleOperationParameter('Condition');
175
    }
176
177
    /**
178
     * Sets the condition of the items to return: New | Used | Collectible | Refurbished | All
179
     *
180
     * Defaults to New.
181
     *
182
     * @param string $condition
183
     *
184
     * @return \ApaiIO\Operations\Search
185
     */
186 2
    public function setCondition($condition)
187
    {
188 2
        $this->parameter['Condition'] = $condition;
189
190 2
        return $this;
191
    }
192
193
    /**
194
     * Returns the availability.
195
     *
196
     * @return string
197
     */
198 2
    public function getAvailability()
199
    {
200 2
        return $this->getSingleOperationParameter('Availability');
201
    }
202
203
    /**
204
     * Sets the availability. Don't use method if you want the default Amazon behaviour.
205
     * Only valid value = Available
206
     *
207
     * @param string $availability
208
     * @see http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CHAP_ReturningPriceAndAvailabilityInformation-itemsearch.html
209
     *
210
     * @return \ApaiIO\Operations\Search
211
     */
212 2
    public function setAvailability($availability)
213
    {
214 2
        $this->parameter['Availability'] = $availability;
215
216 2
        return $this;
217
    }
218
219
    /**
220
     * Returns the browseNodeId
221
     *
222
     * @return integer
223
     */
224 2
    public function getBrowseNode()
225
    {
226 2
        return $this->getSingleOperationParameter('BrowseNode');
227
    }
228
229
    /**
230
     * Sets the browseNodeId
231
     *
232
     * @param integer $browseNodeId
233
     *
234
     * @return \ApaiIO\Operations\Search
235
     */
236 2
    public function setBrowseNode($browseNodeId)
237
    {
238 2
        $this->parameter['BrowseNode'] = $browseNodeId;
239
240 2
        return $this;
241
    }
242
243
    /**
244
     * Validates the given price.
245
     *
246
     * @param integer $price
247
     */
248 6
    protected function validatePrice($price)
249
    {
250 6 View Code Duplication
        if (false === is_numeric($price) || $price < 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
251 2
            throw new \InvalidArgumentException(sprintf('%s is an invalid price value. It has to be numeric and >= than 1',
252 2
                    $price));
253
        }
254 4
    }
255
}
256