1 | <?php |
||
26 | class GetTranslationsArray implements \badams\MicrosoftTranslator\ApiMethodInterface |
||
27 | { |
||
28 | const MAX_TEXTS = 10; |
||
29 | |||
30 | /** |
||
31 | * @const Maximum allowable length of text |
||
32 | */ |
||
33 | const TEXT_MAX_LENGTH = 10000; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $texts; |
||
39 | |||
40 | /** |
||
41 | * @var Language |
||
42 | */ |
||
43 | protected $to; |
||
44 | |||
45 | /** |
||
46 | * @var Language|null |
||
47 | */ |
||
48 | protected $from; |
||
49 | |||
50 | /** |
||
51 | * @var int |
||
52 | */ |
||
53 | protected $maxTranslations; |
||
54 | |||
55 | /** |
||
56 | * @var TranslateOptions |
||
57 | */ |
||
58 | protected $options; |
||
59 | |||
60 | /** |
||
61 | * GetTranslationsArray constructor. |
||
62 | * @param $texts |
||
63 | * @param $to |
||
64 | * @param $from |
||
65 | * @param int $maxTranslations |
||
66 | * @param TranslateOptions|null $options |
||
67 | * @throws ArgumentException |
||
68 | * @throws UnsupportedLanguageException |
||
69 | */ |
||
70 | 15 | public function __construct($texts, $to, $from, $maxTranslations = 5, TranslateOptions $options = null) |
|
82 | |||
83 | /** |
||
84 | * @throws ArgumentException |
||
85 | */ |
||
86 | 15 | protected function assertTextsIsArray() |
|
92 | |||
93 | /** |
||
94 | * @throws ArgumentException |
||
95 | */ |
||
96 | 12 | protected function assertTextsCount() |
|
102 | |||
103 | /** |
||
104 | * @throws ArgumentException |
||
105 | */ |
||
106 | 9 | protected function assertTextsLength() |
|
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | 3 | public function getRequestMethod() |
|
122 | |||
123 | /** |
||
124 | * @return array |
||
125 | */ |
||
126 | 3 | public function getRequestOptions() |
|
130 | |||
131 | /** |
||
132 | * @return string |
||
133 | */ |
||
134 | 6 | protected function createBodyXml() |
|
152 | |||
153 | /** |
||
154 | * @param \DOMDocument $xml |
||
155 | * @param \DOMNode $root |
||
156 | */ |
||
157 | 6 | protected function appendTextsNode(\DOMDocument $xml, \DOMNode $root) |
|
168 | |||
169 | /** |
||
170 | * @param \DOMDocument $xml |
||
171 | * @param \DOMNode $root |
||
172 | */ |
||
173 | 6 | protected function appendOptionsNode(\DOMDocument $xml, \DOMNode $root) |
|
179 | |||
180 | /** |
||
181 | * @param \GuzzleHttp\Message\ResponseInterface $response |
||
182 | * @return GetTranslationsResponse[] |
||
183 | */ |
||
184 | 3 | public function processResponse(\GuzzleHttp\Message\ResponseInterface $response) |
|
196 | } |
||
197 |