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
Pull Request — master (#99)
by
unknown
07:26
created

Lookup::getItemId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 1
cts 1
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 lookup operation
22
 *
23
 * @see    http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/ItemLookup.html
24
 * @author Jan Eichhorn <[email protected]>
25
 */
26
class Lookup extends AbstractOperation
27
{
28
    const TYPE_ASIN = 'ASIN';
29
    const TYPE_SKU = 'SKU';
30
    const TYPE_UPC = 'UPC';
31
    const TYPE_EAN = 'EAN';
32
    const TYPE_ISBN = 'ISBN';
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function getName()
38
    {
39 1
        return 'ItemLookup';
40
    }
41
42
    /**
43
     * Pass up to 10 itemid's which should be looked up
44
     *
45
     * @param array $itemIds
46
     *
47
     * @return \ApaiIO\Operations\Lookup
48
     */
49 2
    public function setItemIds(array $itemIds)
50
    {
51 2
        if (count($itemIds) > 10) {
52 1
            throw new \Exception('setItemIds accepts not more then 10 itemid\'s at once');
53
        }
54
55 1
        $asinString = implode(',', $itemIds);
56 1
        $this->setItemId($asinString);
57
58 1
        return $this;
59
    }
60
61
    /**
62
     * Returns the itemid
63
     *
64
     * @return string
65
     */
66
    public function getItemId()
67
    {
68 2
        return $this->getSingleOperationParameter('ItemId');
69
    }
70 2
71
    /**
72 2
     * Sets the itemid which should be looked up
73
     *
74
     * @param string $itemId
75
     *
76
     * @return \ApaiIO\Operations\Lookup
77
     */
78
    public function setItemId($itemId)
79
    {
80
        $this->parameter['ItemId'] = $itemId;
81
82 7
        return $this;
83
    }
84
85 7
    /**
86 7
     * Returns the idtype either ASIN (Default), SKU, UPC, EAN, and ISBN
87 7
     *
88 7
     * @return string
89
     */
90 7
    public function getIdType()
91
    {
92 7
        return $this->getSingleOperationParameter('IdType');
93 1
    }
94 1
95 1
    /**
96 1
     * Sets the idtype either ASIN (Default), SKU, UPC, EAN, and ISBN
97 1
     *
98
     * @param string $idType
99
     *
100 6
     * @return \ApaiIO\Operations\Lookup
101
     */
102 6
    public function setIdType($idType)
103 5
    {
104 5
        $idTypes = array(
105
            self::TYPE_ASIN,
106 6
            self::TYPE_SKU,
107
            self::TYPE_UPC,
108
            self::TYPE_EAN,
109
            self::TYPE_ISBN
110
        );
111
112
        if (!in_array($idType, $idTypes)) {
113
            throw new \InvalidArgumentException(sprintf(
114
                "Invalid type '%s' passed. Valid types are: '%s'",
115
                $idType,
116 1
                implode(', ', $idTypes)
117
            ));
118 1
        }
119
120 1
        $this->parameter['IdType'] = $idType;
121
122
        if (empty($this->parameter['SearchIndex']) && $idType != self::TYPE_ASIN) {
123
            $this->parameter['SearchIndex'] = 'All';
124
        }
125
126
        return $this;
127
    }
128
129
    /**
130
     * Returns the searchindex
131
     *
132 1
     * @return mixed
133
     */
134 1
    public function getSearchIndex()
135
    {
136 1
        return $this->getSingleOperationParameter('SearchIndex');
137
    }
138
139
    /**
140
     * Sets the searchindex which should be used when set IdType other than ASIN
141
     *
142
     * @param string $searchIndex
143
     *
144
     * @return \ApaiIO\Operations\Lookup
145
     */
146
    public function setSearchIndex($searchIndex)
147
    {
148
        $this->parameter['SearchIndex'] = $searchIndex;
149
150
        return $this;
151
    }
152
153
    /**
154
     * Returns the condition of the items to return. New | Used | Collectible | Refurbished | All
155
     *
156
     * @return string
157
     */
158
    public function getCondition()
159
    {
160
        return $this->getSingleOperationParameter('Condition');
161
    }
162
163
    /**
164
     * Sets the condition of the items to return: New | Used | Collectible | Refurbished | All
165
     *
166
     * Defaults to New.
167
     *
168
     * @param string $condition
169
     *
170
     * @return \ApaiIO\Operations\Search
171
     */
172
    public function setCondition($condition)
173
    {
174
        $this->parameter['Condition'] = $condition;
175
176
        return $this;
177
    }
178
}
179