Total Complexity | 6 |
Total Lines | 78 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | abstract class GetResourceCommand extends ResourceCommand |
||
9 | { |
||
10 | /** |
||
11 | * Resource ID. |
||
12 | */ |
||
13 | protected $resourceId; |
||
14 | |||
15 | /** |
||
16 | * Determines if current command is list command. |
||
17 | * |
||
18 | * @return bool |
||
19 | */ |
||
20 | protected function isListCommand(): bool |
||
21 | { |
||
22 | return false; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * HTTP request method. |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | public function requestMethod() |
||
31 | { |
||
32 | return 'GET'; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Set resource ID. |
||
37 | * |
||
38 | * @param mixed $resourceId |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function setResourceId($resourceId) |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Get resource ID. |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function getResourceId() |
||
55 | { |
||
56 | return $this->resourceId; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Handle command response. |
||
61 | * |
||
62 | * @param ResponseInterface $response |
||
63 | * @param ApiResourceInterface $owner |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public function handleResponse(ResponseInterface $response, ApiResourceInterface $owner) |
||
68 | { |
||
69 | $className = $this->resourceClass(); |
||
70 | |||
71 | return $className::createFromResponse($response, $owner->getApi(), $owner); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * HTTP request URL. |
||
76 | * |
||
77 | * @param ApiResourceInterface $resource |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function requestUrl(ApiResourceInterface $resource) |
||
86 | } |
||
87 | } |
||
88 |