Passed
Push — ymdMonthNames ( 4f0b3e...7ee93b )
by no
08:06
created

MonolingualMonthNameProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 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
	public function __construct( array $monthNames ) {
24
		$this->monthNames = $monthNames;
25
	}
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
	public function getLocalizedMonthNames( $languageCode ) {
33
		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
	public function getMonthNumbers( $languageCode ) {
42
		return array_flip( $this->monthNames );
43
	}
44
45
}
46