1 | <?php |
||
33 | class LinkedIn implements LinkedInInterface |
||
34 | { |
||
35 | /** |
||
36 | * The OAuth access token received in exchange for a valid authorization |
||
37 | * code. null means the access token has yet to be determined. |
||
38 | * |
||
39 | * @var AccessToken |
||
40 | */ |
||
41 | protected $accessToken = null; |
||
42 | |||
43 | /** |
||
44 | * @var string format |
||
45 | */ |
||
46 | private $format; |
||
47 | |||
48 | /** |
||
49 | * @var string responseFormat |
||
50 | */ |
||
51 | private $responseDataType; |
||
52 | |||
53 | /** |
||
54 | * @var RequestManager |
||
55 | */ |
||
56 | private $requestManager; |
||
57 | |||
58 | /** |
||
59 | * @var Authenticator |
||
60 | */ |
||
61 | private $authenticator; |
||
62 | |||
63 | /** |
||
64 | * @var UrlGeneratorInterface |
||
65 | */ |
||
66 | private $urlGenerator; |
||
67 | |||
68 | /** |
||
69 | * Constructor. |
||
70 | * |
||
71 | * @param string $appId |
||
72 | * @param string $appSecret |
||
73 | * @param string $format 'json', 'xml' |
||
74 | * @param string $responseDataType 'array', 'string', 'simple_xml' 'psr7', 'stream' |
||
75 | */ |
||
76 | 7 | public function __construct($appId, $appSecret, $format = 'json', $responseDataType = 'array') |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 1 | public function isAuthenticated() |
|
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | 1 | public function api($method, $resource, array $options = []) |
|
130 | |||
131 | /** |
||
132 | * Modify and filter the request options. Make sure we use the correct query parameters and headers. |
||
133 | * |
||
134 | * @param array &$options |
||
135 | * |
||
136 | * @return string the request format to use |
||
137 | */ |
||
138 | 1 | protected function filterRequestOption(array &$options) |
|
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | 2 | public function getLoginUrl($options = []) |
|
179 | |||
180 | /** |
||
181 | * See docs for LinkedIn::api(). |
||
182 | * |
||
183 | * @param string $resource |
||
184 | * @param array $options |
||
185 | * |
||
186 | * @return mixed |
||
187 | */ |
||
188 | public function get($resource, array $options = []) |
||
192 | |||
193 | /** |
||
194 | * See docs for LinkedIn::api(). |
||
195 | * |
||
196 | * @param string $resource |
||
197 | * @param array $options |
||
198 | * |
||
199 | * @return mixed |
||
200 | */ |
||
201 | public function post($resource, array $options = []) |
||
205 | |||
206 | /** |
||
207 | * {@inheritdoc} |
||
208 | */ |
||
209 | public function clearStorage() |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | 3 | public function hasError() |
|
223 | |||
224 | /** |
||
225 | * {@inheritdoc} |
||
226 | */ |
||
227 | 2 | public function getError() |
|
233 | |||
234 | /** |
||
235 | * Get the default format to use when sending requests. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | 1 | protected function getFormat() |
|
243 | |||
244 | /** |
||
245 | * {@inheritdoc} |
||
246 | */ |
||
247 | 1 | public function setFormat($format) |
|
253 | |||
254 | /** |
||
255 | * Get the default data type to be returned as a response. |
||
256 | * |
||
257 | * @return string |
||
258 | */ |
||
259 | 1 | protected function getResponseDataType() |
|
263 | |||
264 | /** |
||
265 | * {@inheritdoc} |
||
266 | */ |
||
267 | public function setResponseDataType($responseDataType) |
||
273 | |||
274 | /** |
||
275 | * {@inheritdoc} |
||
276 | */ |
||
277 | 1 | public function getAccessToken() |
|
288 | |||
289 | /** |
||
290 | * {@inheritdoc} |
||
291 | */ |
||
292 | 1 | public function setAccessToken($accessToken) |
|
302 | |||
303 | /** |
||
304 | * {@inheritdoc} |
||
305 | */ |
||
306 | 1 | public function setUrlGenerator(UrlGeneratorInterface $urlGenerator) |
|
312 | |||
313 | /** |
||
314 | * @return UrlGeneratorInterface |
||
315 | */ |
||
316 | 2 | protected function getUrlGenerator() |
|
324 | |||
325 | /** |
||
326 | * {@inheritdoc} |
||
327 | */ |
||
328 | public function setStorage(DataStorageInterface $storage) |
||
334 | |||
335 | /** |
||
336 | * {@inheritdoc} |
||
337 | */ |
||
338 | public function setHttpClient(HttpClient $client) |
||
344 | |||
345 | /** |
||
346 | * {@inheritdoc} |
||
347 | */ |
||
348 | public function setHttpMessageFactory(MessageFactory $factory) |
||
354 | |||
355 | /** |
||
356 | * @return RequestManager |
||
357 | */ |
||
358 | protected function getRequestManager() |
||
362 | |||
363 | /** |
||
364 | * @return Authenticator |
||
365 | */ |
||
366 | protected function getAuthenticator() |
||
370 | |||
371 | |||
372 | /** |
||
373 | * @return \Psr\Http\Message\ResponseInterface |
||
374 | */ |
||
375 | public function getLastResponse() |
||
379 | |||
380 | /** |
||
381 | * @return \Psr\Http\Message\RequestInterface |
||
382 | */ |
||
383 | public function getLastRequest() |
||
387 | } |
||
388 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: