DataValues /
Time
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ValueParsers; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * A monolingual month name and number provider, based on a static array. |
||
| 7 | * |
||
| 8 | * @since 0.8.3 |
||
| 9 | * |
||
| 10 | * @licence GNU GPL v2+ |
||
| 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
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 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 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.