These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of phraseanet/php-sdk. |
||
5 | * |
||
6 | * (c) Alchemy <[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 PhraseanetSDK\Orders; |
||
13 | |||
14 | use PhraseanetSDK\AbstractRepository; |
||
15 | use PhraseanetSDK\Exception\RuntimeException; |
||
16 | |||
17 | class OrderRepository extends AbstractRepository |
||
18 | { |
||
19 | |||
20 | public function listOrders($pageIndex = 0, $pageSize = 20) |
||
21 | { |
||
22 | // 't' param is used for cache busting |
||
23 | $parameters = [ |
||
24 | 'page' => max($pageIndex, 0), |
||
25 | 'per_page' => max($pageSize, 1), |
||
26 | 'includes' => [ 'elements' ], |
||
27 | 't' => time() |
||
28 | ]; |
||
29 | |||
30 | $response = $this->query('GET', 'v2/orders/', $parameters); |
||
31 | |||
32 | if ($response->isEmpty()) { |
||
33 | throw new RuntimeException('Response content is empty'); |
||
34 | } |
||
35 | |||
36 | if (! $response->hasProperty('data')) { |
||
37 | throw new RuntimeException('Missing \'data\' property in response'); |
||
38 | } |
||
39 | |||
40 | if (! $response->hasProperty('meta')) { |
||
41 | throw new RuntimeException('Missing \'meta\' property in response'); |
||
42 | } |
||
43 | |||
44 | $meta = $response->getProperty('meta'); |
||
45 | |||
46 | return new OrderList($response->getProperty('data'), $meta->pagination); |
||
47 | } |
||
48 | |||
49 | public function createOrder($usage, array $recordsIds) |
||
50 | { |
||
51 | $parameters = [ |
||
52 | 'usage' => $usage, |
||
53 | 'deadline' => '', |
||
54 | 'records' => $recordsIds |
||
55 | ]; |
||
56 | |||
57 | $response = $this->query('POST', 'v2/orders/', [], [ 'data' => $parameters ], ['Accept' => 'application/json']); |
||
58 | |||
59 | return new Order($response->getProperty('data')); |
||
0 ignored issues
–
show
|
|||
60 | } |
||
61 | } |
||
62 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.