1 | <?php namespace Lbc; |
||
9 | class GetFrom |
||
10 | { |
||
11 | protected $httpClient; |
||
12 | |||
13 | 12 | public function __construct() |
|
17 | |||
18 | /** |
||
19 | * Return the http client |
||
20 | * (usefull to mock the response for unit testing) |
||
21 | * |
||
22 | * @return Client |
||
23 | */ |
||
24 | 6 | public function getHttpClient() |
|
28 | |||
29 | /** |
||
30 | * retrieve the search result data from the given url |
||
31 | * |
||
32 | * @param $url |
||
33 | * @param bool $detailedAd |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | 4 | public function search($url, $detailedAd = false) |
|
61 | |||
62 | /** |
||
63 | * Retrieve the ad's data from an ad's ID and its category |
||
64 | * |
||
65 | * @param $url |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | 2 | private function adById($id, $category) |
|
73 | |||
74 | /** |
||
75 | * Retrieve the ad's data from the given url |
||
76 | * |
||
77 | * @param $url |
||
78 | * @return array |
||
79 | */ |
||
80 | 4 | private function adByUrl($url) |
|
96 | |||
97 | /** |
||
98 | * Dynamique method to retrive the data by url OR id and category |
||
99 | * |
||
100 | * @return bool|mixed |
||
101 | */ |
||
102 | 4 | public function ad() |
|
114 | |||
115 | 3 | public function __call($method, $arguments) |
|
123 | |||
124 | /** |
||
125 | * Add a little bit of sugar |
||
126 | * |
||
127 | * @param $method |
||
128 | * @param $arguments |
||
129 | * @return mixed |
||
130 | */ |
||
131 | 4 | public static function __callStatic($method, $arguments) |
|
141 | } |
||
142 |