|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Efabrica\TranslationsAutomatization\Tokenizer; |
|
4
|
|
|
|
|
5
|
|
|
class Token |
|
6
|
|
|
{ |
|
7
|
|
|
const TOKEN_TRANSLATION_KEY = 1; |
|
8
|
|
|
|
|
9
|
|
|
const TOKEN_TRANSLATION_CODE = 2; |
|
10
|
|
|
|
|
11
|
|
|
const TOKEN_TARGET_TEXT = 4; |
|
12
|
|
|
|
|
13
|
|
|
const TOKEN_ALL = self::TOKEN_TRANSLATION_KEY | self::TOKEN_TRANSLATION_CODE | self::TOKEN_TARGET_TEXT; |
|
14
|
|
|
|
|
15
|
|
|
private $originalText; |
|
16
|
|
|
|
|
17
|
|
|
private $originalBlock; |
|
18
|
|
|
|
|
19
|
|
|
private $translationKey; |
|
20
|
|
|
|
|
21
|
|
|
private $translationCode; |
|
22
|
|
|
|
|
23
|
|
|
private $targetText; |
|
24
|
|
|
|
|
25
|
|
|
private $textParameters = []; |
|
26
|
|
|
|
|
27
|
88 |
|
public function __construct(string $originalText, string $originalBlock) |
|
28
|
|
|
{ |
|
29
|
88 |
|
$this->originalText = $originalText; |
|
30
|
88 |
|
$this->originalBlock = $originalBlock; |
|
31
|
88 |
|
$this->translationKey = $originalText; |
|
32
|
88 |
|
$this->translationCode = $originalText; |
|
33
|
88 |
|
$this->targetText = $originalText; |
|
34
|
88 |
|
} |
|
35
|
|
|
|
|
36
|
22 |
|
public function getOriginalText(): string |
|
37
|
|
|
{ |
|
38
|
22 |
|
return $this->originalText; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
10 |
|
public function getOriginalBlock(): string |
|
42
|
|
|
{ |
|
43
|
10 |
|
return $this->originalBlock; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
70 |
|
public function getTranslationKey(): string |
|
47
|
|
|
{ |
|
48
|
70 |
|
return $this->translationKey; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
52 |
|
public function changeTranslationKey(string $newTranslationKey): Token |
|
52
|
|
|
{ |
|
53
|
52 |
|
$this->translationKey = $newTranslationKey; |
|
54
|
52 |
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
32 |
|
public function getTranslationCode(): string |
|
58
|
|
|
{ |
|
59
|
32 |
|
return $this->translationCode; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
22 |
|
public function changeTranslationCode(string $newTranslationCode): Token |
|
63
|
|
|
{ |
|
64
|
22 |
|
$this->translationCode = $newTranslationCode; |
|
65
|
22 |
|
return $this; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
48 |
|
public function getTargetText(): string |
|
69
|
|
|
{ |
|
70
|
48 |
|
return $this->targetText; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
26 |
|
public function changeTargetText(string $newTargetText): Token |
|
74
|
|
|
{ |
|
75
|
26 |
|
$this->targetText = $newTargetText; |
|
76
|
26 |
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
28 |
|
public function getTextParameters(): array |
|
80
|
|
|
{ |
|
81
|
28 |
|
return $this->textParameters; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
16 |
|
public function setTextParameters(array $textParameters): Token |
|
85
|
|
|
{ |
|
86
|
16 |
|
$this->textParameters = $textParameters; |
|
87
|
16 |
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|