1 | <?php |
||
15 | class TermFallback extends Term { |
||
16 | |||
17 | /** |
||
18 | * @var string Actual language of the text. |
||
19 | */ |
||
20 | private $actualLanguageCode; |
||
21 | |||
22 | /** |
||
23 | * @var string|null Source language if the text is a transliteration. |
||
24 | */ |
||
25 | private $sourceLanguageCode; |
||
26 | |||
27 | /** |
||
28 | * @param string $requestedLanguageCode Requested language, not necessarily the language of the |
||
29 | * text. |
||
30 | * @param string $text |
||
31 | * @param string $actualLanguageCode Actual language of the text. |
||
32 | * @param string|null $sourceLanguageCode Source language if the text is a transliteration. |
||
33 | * |
||
34 | * @throws InvalidArgumentException |
||
35 | */ |
||
36 | public function __construct( $requestedLanguageCode, $text, $actualLanguageCode, $sourceLanguageCode ) { |
||
37 | parent::__construct( $requestedLanguageCode, $text ); |
||
38 | |||
39 | if ( !is_string( $actualLanguageCode ) || $actualLanguageCode === '' ) { |
||
40 | throw new InvalidArgumentException( '$actualLanguageCode must be a non-empty string' ); |
||
41 | } |
||
42 | |||
43 | if ( !( $sourceLanguageCode === null |
||
44 | || ( is_string( $sourceLanguageCode ) && $sourceLanguageCode !== '' ) |
||
45 | ) ) { |
||
46 | throw new InvalidArgumentException( '$sourceLanguageCode must be a non-empty string or null' ); |
||
47 | } |
||
48 | |||
49 | $this->actualLanguageCode = $actualLanguageCode; |
||
50 | $this->sourceLanguageCode = $sourceLanguageCode; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getActualLanguageCode() { |
||
59 | |||
60 | /** |
||
61 | * @return string|null |
||
62 | */ |
||
63 | public function getSourceLanguageCode() { |
||
66 | |||
67 | /** |
||
68 | * @see Comparable::equals |
||
69 | * |
||
70 | * @param mixed $target |
||
71 | * |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function equals( $target ) { |
||
84 | |||
85 | } |
||
86 |