1 | <?php |
||
10 | abstract class AbstractApiCall implements ApiInterface |
||
11 | { |
||
12 | /** |
||
13 | * Goutte Client. |
||
14 | * |
||
15 | * @var Client |
||
16 | */ |
||
17 | protected $client; |
||
18 | |||
19 | /** |
||
20 | * auto mapper. |
||
21 | * |
||
22 | * @var AutoMapper |
||
23 | */ |
||
24 | protected $automapper; |
||
25 | |||
26 | public function __construct() |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function author($name) |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function browse($type) |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function search($keywords) |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function slug($slug) |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public function tag($tag) |
||
81 | |||
82 | /** |
||
83 | * make the actual API call. |
||
84 | * |
||
85 | * @param string $type information or query |
||
86 | * @param array $arguments arguments to query |
||
87 | * |
||
88 | * @return mixed |
||
89 | */ |
||
90 | protected function makeApiCall($type, array $arguments) |
||
101 | |||
102 | protected function mapResponseToCollection(\stdClass $response) |
||
116 | |||
117 | protected function mapResponseToModel(\stdClass $response) |
||
124 | |||
125 | /** |
||
126 | * map response to model. |
||
127 | * |
||
128 | * @param \stdClass $response |
||
129 | * |
||
130 | * @return mixed |
||
131 | */ |
||
132 | protected function mapResponse(\stdClass $response) |
||
140 | |||
141 | /** |
||
142 | * get API action. |
||
143 | * |
||
144 | * @param string $type |
||
145 | * |
||
146 | * @return string formatted action |
||
147 | */ |
||
148 | protected function getAction($type) |
||
156 | |||
157 | /** |
||
158 | * get URI of API. |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | protected function getUri() |
||
166 | |||
167 | /** |
||
168 | * get the type of object to query. |
||
169 | * |
||
170 | * @return string |
||
171 | */ |
||
172 | abstract protected function getType(); |
||
173 | |||
174 | /** |
||
175 | * create model. |
||
176 | * |
||
177 | * @return mixed |
||
178 | */ |
||
179 | abstract protected function createModel(); |
||
180 | } |
||
181 |