Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class AlifTransliterator extends HttpTransliteratorAbstract |
||
12 | { |
||
13 | /** @var string */ |
||
14 | protected const API_URI = 'http://www.alif.uz/api/translit/'; |
||
15 | |||
16 | /** |
||
17 | * @inheritDoc |
||
18 | */ |
||
19 | 24 | protected function getDefaultOptions(): array |
|
20 | { |
||
21 | return [ |
||
22 | 24 | \CURLOPT_URL => self::API_URI, |
|
23 | \CURLOPT_POST => true, |
||
24 | \CURLOPT_HTTPHEADER => [ |
||
25 | 'Accept: application/json; charset=utf-8', |
||
26 | 'Content-Type: application/json; charset=utf-8', |
||
27 | ], |
||
28 | ]; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @inheritDoc |
||
33 | */ |
||
34 | protected function getPerRequestOptions(): array |
||
35 | { |
||
36 | return [ |
||
37 | \CURLOPT_POSTFIELDS => json_encode([ |
||
38 | 'inputText' => $this->getText(), |
||
39 | 'isLatToCyr' => $this->isToCyrillic() ? 'true' : 'false', |
||
40 | ]), |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @inheritDoc |
||
46 | */ |
||
47 | 6 | protected function getResultFromResponse(string $response): string |
|
50 | } |
||
51 | } |
||
52 |