1 | <?php |
||
21 | class Browser |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $host; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $api_prefix; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $app_code; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $image_prefix; |
||
42 | |||
43 | /** |
||
44 | * @var Client |
||
45 | */ |
||
46 | private $client; |
||
47 | |||
48 | /** |
||
49 | * @var CacheResponse |
||
50 | */ |
||
51 | private $cache; |
||
52 | |||
53 | /** |
||
54 | * @var ResponseRepair |
||
55 | */ |
||
56 | private $response_repair; |
||
57 | |||
58 | /** |
||
59 | * @param Client $client |
||
60 | * @param ResponseRepair $response_repair |
||
61 | * @param string $host |
||
62 | * @param string $api_prefix |
||
63 | * @param string $api_client |
||
64 | * @param string $api_clientver |
||
65 | * @param string $api_protover |
||
66 | * @param string $app_code |
||
67 | * @param string $image_prefix |
||
68 | */ |
||
69 | 9 | public function __construct( |
|
70 | Client $client, |
||
71 | ResponseRepair $response_repair, |
||
72 | $host, |
||
73 | $api_prefix, |
||
74 | $api_client, |
||
75 | $api_clientver, |
||
76 | $api_protover, |
||
77 | $app_code, |
||
78 | $image_prefix |
||
79 | ) { |
||
80 | 9 | $this->client = $client; |
|
81 | 9 | $api_prefix .= strpos($api_prefix, '?') !== false ? '&' : '?'; |
|
82 | 9 | $api_prefix .= http_build_query([ |
|
83 | 9 | 'client' => $api_client, |
|
84 | 9 | 'clientver' => $api_clientver, |
|
85 | 9 | 'protover' => $api_protover, |
|
86 | 9 | ]); |
|
87 | 9 | $this->host = $host; |
|
88 | 9 | $this->api_prefix = $api_prefix; |
|
89 | 9 | $this->app_code = $app_code; |
|
90 | 9 | $this->image_prefix = $image_prefix; |
|
91 | 9 | $this->response_repair = $response_repair; |
|
92 | 9 | } |
|
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | 1 | public function getHost() |
|
101 | |||
102 | /** |
||
103 | * @return string |
||
104 | */ |
||
105 | 2 | public function getApiHost() |
|
109 | |||
110 | /** |
||
111 | * @param int $timeout |
||
112 | * |
||
113 | * @return Browser |
||
114 | */ |
||
115 | 1 | public function setTimeout($timeout) |
|
121 | |||
122 | /** |
||
123 | * @param string $proxy |
||
124 | * |
||
125 | * @return Browser |
||
126 | */ |
||
127 | 1 | public function setProxy($proxy) |
|
133 | |||
134 | /** |
||
135 | * @param CacheResponse $cache |
||
136 | */ |
||
137 | 2 | public function setResponseCache(CacheResponse $cache) |
|
141 | |||
142 | /** |
||
143 | * @deprecated get() is deprecated since AniDbBrowser 2.0. Use getCrawler() instead |
||
144 | * |
||
145 | * @param string $request |
||
146 | * @param array $params |
||
147 | * @param bool $force |
||
148 | * |
||
149 | * @return Crawler |
||
150 | */ |
||
151 | public function get($request, array $params = [], $force = false) |
||
152 | { |
||
153 | return $this->getCrawler($request, $params, $force); |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @param string $request |
||
158 | * @param array $params |
||
159 | * @param bool $force |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | 4 | public function getContent($request, array $params = [], $force = false) |
|
184 | |||
185 | /** |
||
186 | * @param string $request |
||
187 | * @param array $params |
||
188 | * @param bool $force |
||
189 | * |
||
190 | * @return Crawler |
||
191 | */ |
||
192 | 4 | public function getCrawler($request, array $params = [], $force = false) |
|
196 | |||
197 | /** |
||
198 | * @param string $image |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | 1 | public function getImageUrl($image) |
|
206 | } |
||
207 |