Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
TranslationUnit | |
0.00% |
0 / 14 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
getTranslationId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSectionId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSequenceId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOrigin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTimestamp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getValidate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Value object for translation section. |
4 | * |
5 | * @copyright See AUTHORS.txt |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | |
9 | namespace ContentTranslation\Entity; |
10 | |
11 | class TranslationUnit { |
12 | protected int $translationId; |
13 | /** @var string */ |
14 | protected $sectionId; |
15 | /** @var string */ |
16 | protected $origin; |
17 | /** @var int|null */ |
18 | protected $sequenceId; |
19 | /** @var string */ |
20 | protected $content; |
21 | /** @var string */ |
22 | protected $timestamp; |
23 | /** @var bool|null */ |
24 | protected $validate; |
25 | |
26 | public function __construct( |
27 | string $sectionId, |
28 | string $origin, |
29 | ?int $sequenceId, |
30 | string $content, |
31 | int $translationId, |
32 | ?string $timestamp = null, |
33 | ?bool $validate = false |
34 | ) { |
35 | // Truncate section id to fit in the database column. The frontend is aware of this |
36 | // limitation and checks the id from content itself if the length is 30 bytes. Also |
37 | // cxserver is aware of this limitation and it should not produce ids that are over |
38 | // 30 bytes. Also, the database does not actually complain unless it is in a strict |
39 | // mode, which is not yet the case for Wikimedia deployment. |
40 | $this->sectionId = substr( $sectionId, 0, 30 ); |
41 | $this->origin = $origin; |
42 | $this->sequenceId = $sequenceId; |
43 | $this->content = $content; |
44 | $this->translationId = $translationId; |
45 | $this->timestamp = $timestamp ?? wfTimestamp(); |
46 | $this->validate = $validate; |
47 | } |
48 | |
49 | public function getTranslationId(): int { |
50 | return $this->translationId; |
51 | } |
52 | |
53 | public function getSectionId(): string { |
54 | return $this->sectionId; |
55 | } |
56 | |
57 | public function getSequenceId(): ?int { |
58 | return $this->sequenceId; |
59 | } |
60 | |
61 | public function getOrigin(): string { |
62 | return $this->origin; |
63 | } |
64 | |
65 | public function getTimestamp(): string { |
66 | return $this->timestamp; |
67 | } |
68 | |
69 | public function getContent(): string { |
70 | return $this->content; |
71 | } |
72 | |
73 | public function getValidate(): ?bool { |
74 | return $this->validate; |
75 | } |
76 | } |