Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ConstantLanguageGuesser | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
guessLang | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Language; |
5 | |
6 | use Wikimedia\Bcp47Code\Bcp47Code; |
7 | use Wikimedia\Parsoid\DOM\Element; |
8 | |
9 | /** |
10 | * A simple {@link LanguageGuesser} that returns the same "source language" for every node. |
11 | * Appropriate for wikis which by convention are written in a single variant. |
12 | */ |
13 | class ConstantLanguageGuesser extends LanguageGuesser { |
14 | |
15 | /** @var Bcp47Code */ |
16 | private $langCode; |
17 | |
18 | /** |
19 | * @param Bcp47Code $langCode a language code |
20 | */ |
21 | public function __construct( Bcp47Code $langCode ) { |
22 | $this->langCode = $langCode; |
23 | } |
24 | |
25 | /** @inheritDoc */ |
26 | public function guessLang( Element $node ): Bcp47Code { |
27 | return $this->langCode; |
28 | } |
29 | |
30 | } |