1 | <?php |
||
11 | class GetFrom |
||
12 | { |
||
13 | protected $httpClient; |
||
14 | |||
15 | 12 | public function __construct(Client $client = null) |
|
19 | |||
20 | /** |
||
21 | * Return the http client |
||
22 | * (useful to mock the response for unit testing) |
||
23 | * |
||
24 | * @return Client |
||
25 | */ |
||
26 | public function getHttpClient() |
||
30 | |||
31 | /** |
||
32 | * retrieve the search result data from the given url |
||
33 | * |
||
34 | * @param $url |
||
35 | * @param bool $detailedAd |
||
36 | * |
||
37 | * @return array |
||
38 | */ |
||
39 | 4 | public function search($url, $detailedAd = false) |
|
63 | |||
64 | /** |
||
65 | * Retrieve the ad's data from an ad's ID and its category |
||
66 | * |
||
67 | * @param $id |
||
68 | * @param $category |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | 2 | private function adById($id, $category) |
|
76 | |||
77 | /** |
||
78 | * Retrieve the ad's data from the given url |
||
79 | * |
||
80 | * @param $url |
||
81 | * @return array |
||
82 | */ |
||
83 | 2 | private function adByUrl($url) |
|
99 | |||
100 | /** |
||
101 | * Dynamique method to retrive the data by url OR id and category |
||
102 | * |
||
103 | * @return bool|mixed |
||
104 | */ |
||
105 | 4 | public function ad() |
|
117 | |||
118 | 2 | public function __call($method, $arguments) |
|
126 | |||
127 | /** |
||
128 | * Add a little bit of sugar |
||
129 | * |
||
130 | * @param $method |
||
131 | * @param $arguments |
||
132 | * @return mixed |
||
133 | */ |
||
134 | 2 | public static function __callStatic($method, $arguments) |
|
144 | } |
||
145 |