1 | <?php |
||
12 | class Resource implements IResource |
||
13 | { |
||
14 | protected $client; |
||
15 | protected $databaseName; |
||
16 | protected $collection; |
||
17 | protected $fullTableName; |
||
18 | protected $resourceName; |
||
19 | protected $primaryKey; |
||
20 | protected $marshaler; |
||
21 | |||
22 | 19 | public function __construct($resourceName, $primaryKey, Client $client = null, $databaseName = null) |
|
31 | |||
32 | 1 | private function createClient() |
|
43 | |||
44 | 1 | private function getFullDatabaseName() |
|
48 | |||
49 | 2 | public function get($resourceId = null) |
|
56 | |||
57 | 1 | protected function getOne($resourceId) |
|
63 | |||
64 | 1 | protected function createGetQuery($resourceId) |
|
72 | |||
73 | 1 | protected function getAll() |
|
79 | |||
80 | 1 | protected function createScanQuery() |
|
87 | |||
88 | 2 | protected function throwAwsPostError($exception) |
|
89 | { |
||
90 | 2 | switch ($exception->getAwsErrorCode()) { |
|
91 | 2 | case 'ConditionalCheckFailedException': |
|
92 | 1 | throw new RestException( |
|
93 | 1 | 'Primary key collision', |
|
94 | 1 | ['exception' => $exception] |
|
95 | ); |
||
96 | } |
||
97 | 1 | throw new RestException($exception->getMessage(), ['exception' => $exception]); |
|
98 | } |
||
99 | |||
100 | 6 | public function post($newResource) |
|
112 | |||
113 | 6 | protected function createPostQuery($newResource) |
|
123 | |||
124 | 2 | protected function throwAwsPutError($exception) |
|
125 | { |
||
126 | 2 | switch ($exception->getAwsErrorCode()) { |
|
127 | 2 | case 'ConditionalCheckFailedException': |
|
128 | 1 | throw new RestException( |
|
129 | 1 | 'Resource does not exist', |
|
130 | 1 | ['exception' => $exception] |
|
131 | ); |
||
132 | } |
||
133 | 1 | throw new RestException($exception->getMessage(), ['exception' => $exception]); |
|
134 | } |
||
135 | |||
136 | 5 | public function put($resourceId, $newResource) |
|
137 | { |
||
138 | try { |
||
139 | 5 | $newResource->{$this->primaryKey} = $resourceId; |
|
140 | 5 | $query = $this->createPutQuery($newResource); |
|
141 | 5 | $res = $this->client->putItem($query); |
|
142 | 3 | } catch (DynamoDbException $ex) { |
|
143 | 2 | $this->throwAwsPutError($ex); |
|
144 | 1 | } catch (\Exception $ex) { |
|
145 | 1 | throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]); |
|
146 | } |
||
147 | 2 | return $newResource; |
|
148 | } |
||
149 | |||
150 | 5 | protected function createPutQuery($newResource) |
|
160 | |||
161 | 2 | public function delete($resourceId) |
|
171 | |||
172 | 2 | protected function createDeleteQuery($resourceId) |
|
180 | |||
181 | 14 | protected function marshalItem($resource) |
|
185 | |||
186 | 3 | protected function unmarshalItem($item) |
|
193 | |||
194 | 2 | protected function unmarshalBatch($itemList) |
|
205 | } |
||
206 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.