Completed
Push — master ( 37509a...6fde37 )
by
unknown
02:20
created

MonolingualMonthNameProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 33
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 Mättig
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
	function __construct( array $monthNames ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for __construct.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
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