1 | <?php |
||
27 | class GetTranslationsArray implements \badams\MicrosoftTranslator\ApiMethodInterface |
||
28 | { |
||
29 | const MAX_TEXTS = 10; |
||
30 | |||
31 | /** |
||
32 | * @const Maximum allowable length of text |
||
33 | */ |
||
34 | const TEXT_MAX_LENGTH = 10000; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $texts; |
||
40 | |||
41 | /** |
||
42 | * @var Language |
||
43 | */ |
||
44 | protected $to; |
||
45 | |||
46 | /** |
||
47 | * @var Language|null |
||
48 | */ |
||
49 | protected $from; |
||
50 | |||
51 | /** |
||
52 | * @var int |
||
53 | */ |
||
54 | protected $maxTranslations; |
||
55 | |||
56 | /** |
||
57 | * @var TranslateOptions |
||
58 | */ |
||
59 | protected $options; |
||
60 | |||
61 | /** |
||
62 | * GetTranslationsArray constructor. |
||
63 | * @param $texts |
||
64 | * @param $to |
||
65 | * @param $from |
||
66 | * @param int $maxTranslations |
||
67 | * @param TranslateOptions|null $options |
||
68 | * @throws ArgumentException |
||
69 | * @throws UnsupportedLanguageException |
||
70 | */ |
||
71 | 15 | public function __construct($texts, $to, $from, $maxTranslations = 5, TranslateOptions $options = null) |
|
83 | |||
84 | /** |
||
85 | * @throws ArgumentException |
||
86 | */ |
||
87 | 15 | protected function assertTextsIsArray() |
|
93 | |||
94 | /** |
||
95 | * @throws ArgumentException |
||
96 | */ |
||
97 | 12 | protected function assertTextsCount() |
|
103 | |||
104 | /** |
||
105 | * @throws ArgumentException |
||
106 | */ |
||
107 | 9 | protected function assertTextsLength() |
|
115 | |||
116 | /** |
||
117 | * @return string |
||
118 | */ |
||
119 | 3 | public function getRequestMethod() |
|
123 | |||
124 | /** |
||
125 | * @return array |
||
126 | */ |
||
127 | 3 | public function getRequestOptions() |
|
131 | |||
132 | /** |
||
133 | * @return string |
||
134 | */ |
||
135 | 6 | protected function createBodyXml() |
|
164 | |||
165 | /** |
||
166 | * @param \GuzzleHttp\Message\ResponseInterface $response |
||
167 | * @return GetTranslationsResponse[] |
||
168 | */ |
||
169 | 3 | public function processResponse(\GuzzleHttp\Message\ResponseInterface $response) |
|
181 | |||
182 | } |