Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| Suggestion | |
0.00% |
0 / 13 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| newFromRow | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSourceLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTargetLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace ContentTranslation; |
| 4 | |
| 5 | use MediaWiki\Title\Title; |
| 6 | use stdClass; |
| 7 | |
| 8 | class Suggestion { |
| 9 | protected string $title; |
| 10 | protected string $sourceLanguage; |
| 11 | protected string $targetLanguage; |
| 12 | |
| 13 | public function __construct( array $params ) { |
| 14 | $this->title = (string)$params['title']; |
| 15 | $this->sourceLanguage = (string)$params['sourceLanguage']; |
| 16 | $this->targetLanguage = (string)$params['targetLanguage']; |
| 17 | } |
| 18 | |
| 19 | public static function newFromRow( stdClass $row ): self { |
| 20 | $params = [ |
| 21 | 'title' => $row->cxs_title, |
| 22 | 'sourceLanguage' => $row->cxs_source_language, |
| 23 | 'targetLanguage' => $row->cxs_target_language, |
| 24 | ]; |
| 25 | |
| 26 | return new self( $params ); |
| 27 | } |
| 28 | |
| 29 | public function getTitle(): ?Title { |
| 30 | return Title::newFromText( $this->title ); |
| 31 | } |
| 32 | |
| 33 | public function getSourceLanguage(): string { |
| 34 | return $this->sourceLanguage; |
| 35 | } |
| 36 | |
| 37 | public function getTargetLanguage(): string { |
| 38 | return $this->targetLanguage; |
| 39 | } |
| 40 | |
| 41 | public function __toString(): string { |
| 42 | return $this->title; |
| 43 | } |
| 44 | } |