Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| TranslationUnit | |
0.00% |
0 / 9 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
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 | private string $sectionId; |
| 13 | private string $timestamp; |
| 14 | |
| 15 | public function __construct( |
| 16 | string $sectionId, |
| 17 | private readonly string $origin, |
| 18 | private readonly ?int $sequenceId, |
| 19 | private readonly string $content, |
| 20 | private readonly int $translationId, |
| 21 | ?string $timestamp = null, |
| 22 | private readonly ?bool $validate = false |
| 23 | ) { |
| 24 | // Truncate section id to fit in the database column. The frontend is aware of this |
| 25 | // limitation and checks the id from content itself if the length is 30 bytes. Also |
| 26 | // cxserver is aware of this limitation and it should not produce ids that are over |
| 27 | // 30 bytes. Also, the database does not actually complain unless it is in a strict |
| 28 | // mode, which is not yet the case for Wikimedia deployment. |
| 29 | $this->sectionId = substr( $sectionId, 0, 30 ); |
| 30 | $this->timestamp = $timestamp ?? wfTimestamp(); |
| 31 | } |
| 32 | |
| 33 | public function getTranslationId(): int { |
| 34 | return $this->translationId; |
| 35 | } |
| 36 | |
| 37 | public function getSectionId(): string { |
| 38 | return $this->sectionId; |
| 39 | } |
| 40 | |
| 41 | public function getSequenceId(): ?int { |
| 42 | return $this->sequenceId; |
| 43 | } |
| 44 | |
| 45 | public function getOrigin(): string { |
| 46 | return $this->origin; |
| 47 | } |
| 48 | |
| 49 | public function getTimestamp(): string { |
| 50 | return $this->timestamp; |
| 51 | } |
| 52 | |
| 53 | public function getContent(): string { |
| 54 | return $this->content; |
| 55 | } |
| 56 | |
| 57 | public function getValidate(): ?bool { |
| 58 | return $this->validate; |
| 59 | } |
| 60 | } |