MonolingualMonthNameProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 33
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getLocalizedMonthNames() 0 3 1
A getMonthNumbers() 0 3 1
1
<?php
2
3
namespace ValueParsers;
4
5
/**
6
 * A monolingual month name and month number provider, based on a static array.
7
 *
8
 * @since 0.8.4
9
 *
10
 * @license GPL-2.0+
11
 * @author Thiemo Kreuz
12
 */
13
class MonolingualMonthNameProvider implements MonthNameProvider {
14
15
	/**
16
	 * @var string[]
17
	 */
18
	private $monthNames;
19
20
	/**
21
	 * @param string[] $monthNames Array mapping month numbers (1 to 12) to localized month names.
22
	 */
23 2
	public function __construct( array $monthNames ) {
24 2
		$this->monthNames = $monthNames;
25 2
	}
26
27
	/**
28
	 * @param string $languageCode Ignored in this implementation.
29
	 *
30
	 * @return string[] Array mapping month numbers (1 to 12) to localized month names.
31
	 */
32 1
	public function getLocalizedMonthNames( $languageCode ) {
33 1
		return $this->monthNames;
34
	}
35
36
	/**
37
	 * @param string $languageCode Ignored in this implementation.
38
	 *
39
	 * @return int[] Array mapping localized month names to month numbers (1 to 12).
40
	 */
41 1
	public function getMonthNumbers( $languageCode ) {
42 1
		return array_flip( $this->monthNames );
43
	}
44
45
}
46