1 | <?php |
||
24 | class Translate implements \badams\MicrosoftTranslator\ApiMethodInterface |
||
25 | { |
||
26 | /** |
||
27 | * @const Maximum allowable length of text |
||
28 | */ |
||
29 | const TEXT_MAX_LENGTH = 10000; |
||
30 | |||
31 | /** |
||
32 | * @const Html content type, HTML needs to be well-formed. |
||
33 | */ |
||
34 | const CONTENT_TYPE_HTML = 'text/html'; |
||
35 | |||
36 | /** |
||
37 | * @const plain text content type |
||
38 | */ |
||
39 | const CONTENT_TYPE_PLAIN = 'text/plain'; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $text; |
||
45 | |||
46 | /** |
||
47 | * @var Language |
||
48 | */ |
||
49 | protected $to; |
||
50 | |||
51 | /** |
||
52 | * @var Language|null |
||
53 | */ |
||
54 | protected $from; |
||
55 | |||
56 | /** |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $contentType; |
||
60 | |||
61 | /** |
||
62 | * Translate constructor. |
||
63 | * @param $text |
||
64 | * @param $to |
||
65 | * @param null $from |
||
66 | * @param string $contentType |
||
67 | */ |
||
68 | 27 | public function __construct($text, $to, $from = null, $contentType = Translate::CONTENT_TYPE_PLAIN) |
|
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | 18 | public function getRequestMethod() |
|
95 | |||
96 | /** |
||
97 | * @return array |
||
98 | */ |
||
99 | 18 | public function getRequestOptions() |
|
110 | |||
111 | /** |
||
112 | * @param \GuzzleHttp\Message\ResponseInterface $response |
||
113 | * @return string |
||
114 | */ |
||
115 | 9 | public function processResponse(\GuzzleHttp\Message\ResponseInterface $response) |
|
120 | } |
||
121 |