MediaWikiLanguageDirectionalityLookup   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDirectionality() 0 9 2
1
<?php
2
3
namespace Wikibase\Repo;
4
5
use Language;
6
use MWException;
7
use Wikibase\View\LanguageDirectionalityLookup;
8
9
/**
10
 * Service for looking up language directionalities based on MediaWiki's Language
11
 * class.
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Adrian Heine <[email protected]>
15
 */
16
class MediaWikiLanguageDirectionalityLookup implements LanguageDirectionalityLookup {
17
18
	/**
19
	 * @see LanguageDirectionalityLookup::getDirectionality
20
	 *
21
	 * @param string $languageCode
22
	 *
23
	 * @return string|null 'ltr', 'rtl' or null if unknown
24
	 */
25
	public function getDirectionality( $languageCode ) {
26
		try {
27
			$lang = Language::factory( $languageCode );
28
		} catch ( MWException $ex ) {
0 ignored issues
show
Bug introduced by
The class MWException does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
29
			return null;
30
		}
31
32
		return $lang->getDir();
33
	}
34
35
}
36