Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| Language | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
| getConverter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setConverter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isValidInternalCode | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| fetchLanguageNames | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\Parsoid\Language; |
| 5 | |
| 6 | /** |
| 7 | * Base class for Language objects. |
| 8 | */ |
| 9 | class Language { |
| 10 | |
| 11 | /** @var LanguageConverter|null */ |
| 12 | private $converter; |
| 13 | |
| 14 | public function getConverter(): ?LanguageConverter { |
| 15 | return $this->converter; |
| 16 | } |
| 17 | |
| 18 | public function setConverter( LanguageConverter $converter ): void { |
| 19 | $this->converter = $converter; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Returns true if a language code string is of a valid form, whether or not it exists. |
| 24 | * This includes codes which are used solely for customisation via the MediaWiki namespace. |
| 25 | * @param string $code a MediaWiki-internal code |
| 26 | * @return bool |
| 27 | */ |
| 28 | public static function isValidInternalCode( string $code ): bool { |
| 29 | static $validityCache = []; |
| 30 | if ( !isset( $validityCache[$code] ) ) { |
| 31 | $validityCache[$code] = strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code ) && |
| 32 | // XXX Core's version also checks against |
| 33 | // !preg_match( MediaWikiTitleCodec::getTitleInvalidRegex(), $code ) && |
| 34 | strlen( $code ) <= 128; |
| 35 | } |
| 36 | return $validityCache[$code]; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get an array of language names, indexed by code. |
| 41 | * @param string $inLanguage Code of language in which to return the names. |
| 42 | * Use null for autonyms (native names) |
| 43 | * @param string $include One of: |
| 44 | * * `all` all available languages |
| 45 | * * `mw` only if the language is defined in MediaWiki or `wgExtraLanguageNames` (default) |
| 46 | * * `mwfile` only if the language is in `mw` *and* has a message file |
| 47 | * @return array |
| 48 | * @deprecated Appears to be unused |
| 49 | */ |
| 50 | public function fetchLanguageNames( string $inLanguage, string $include ): array { |
| 51 | return []; |
| 52 | } |
| 53 | |
| 54 | } |