|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the badams\MicrosoftTranslator library |
|
4
|
|
|
* |
|
5
|
|
|
* @license http://opensource.org/licenses/MIT |
|
6
|
|
|
* @link https://github.com/badams/microsoft-translator |
|
7
|
|
|
* @package badams/microsoft-translator |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace badams\MicrosoftTranslator\Responses; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class TranslationMatch |
|
17
|
|
|
* @package badams\MicrosoftTranslator\Responses |
|
18
|
|
|
* @link https://msdn.microsoft.com/en-us/library/ff512417.aspx |
|
19
|
|
|
*/ |
|
20
|
|
|
class TranslationMatch |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $error; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var int |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $count; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var int |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $matchDegree; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var int |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $rating; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $translatedText; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $matchedOriginalText; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* TranslationMatch constructor. |
|
54
|
|
|
* @param $count |
|
55
|
|
|
* @param $matchDegree |
|
56
|
|
|
* @param $rating |
|
57
|
|
|
* @param $translatedText |
|
58
|
|
|
*/ |
|
59
|
9 |
|
public function __construct($count, $matchDegree, $rating, $translatedText, $matchedOriginalText = null, $error = null) |
|
60
|
|
|
{ |
|
61
|
9 |
|
$this->count = (int)$count; |
|
62
|
9 |
|
$this->matchDegree = (int)$matchDegree; |
|
63
|
9 |
|
$this->rating = (int)$rating; |
|
64
|
9 |
|
$this->translatedText = $translatedText; |
|
65
|
9 |
|
$this->matchedOriginalText = $matchedOriginalText; |
|
66
|
9 |
|
$this->error = $error; |
|
67
|
9 |
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param \SimpleXMLElement $xml |
|
71
|
|
|
* @return TranslationMatch |
|
72
|
|
|
*/ |
|
73
|
9 |
|
public static function fromXmlElement(\SimpleXMLElement $xml) |
|
74
|
|
|
{ |
|
75
|
9 |
|
return new TranslationMatch( |
|
76
|
9 |
|
(string)$xml->Count, |
|
77
|
9 |
|
(string)$xml->MatchDegree, |
|
78
|
9 |
|
(string)$xml->Rating, |
|
79
|
9 |
|
(string)$xml->TranslatedText, |
|
80
|
9 |
|
(string)$xml->MatchedOriginalText |
|
81
|
9 |
|
); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
6 |
|
public function getTranslatedText() |
|
88
|
|
|
{ |
|
89
|
6 |
|
return $this->translatedText; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return int |
|
94
|
|
|
*/ |
|
95
|
6 |
|
public function getMatchDegree() |
|
96
|
|
|
{ |
|
97
|
6 |
|
return $this->matchDegree; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return int |
|
102
|
|
|
*/ |
|
103
|
6 |
|
public function getRating() |
|
104
|
|
|
{ |
|
105
|
6 |
|
return $this->rating; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @return int |
|
110
|
|
|
*/ |
|
111
|
6 |
|
public function getCount() |
|
112
|
|
|
{ |
|
113
|
6 |
|
return $this->count; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return null|string |
|
118
|
|
|
*/ |
|
119
|
6 |
|
public function getError() |
|
120
|
|
|
{ |
|
121
|
6 |
|
return $this->error; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
3 |
|
public function getMatchedOriginalText() |
|
125
|
|
|
{ |
|
126
|
3 |
|
return $this->matchedOriginalText; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|