Passed
Branch scrutinizer (a663d7)
by Wanderson
01:44
created

Month   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 2 2
A getNameAbbre() 0 6 2
1
<?php
2
3
namespace Win\Calendar;
4
5
/**
6
 * Mês
7
 */
8
class Month {
9
10
	/** @var string[] */
11
	public static $names = [1 => 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
12
13
	const ABBRE_LENGTH = 3;
14
15
	/**
16
	 * @param int $month
17
	 * @return string
18
	 */
19
	public static function getName($month) {
20
		return key_exists($month, static::$names) ? static::$names[$month] : false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return key_exists($month...::names[$month] : false could also return false which is incompatible with the documented return type string. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
21
	}
22
23
	/**
24
	 * @param int $month
25
	 * @return string
26
	 */
27
	public static function getNameAbbre($month) {
28
		$name = static::getName($month);
29
		if ($name) {
30
			return strtoupper(substr($name, 0, static::ABBRE_LENGTH));
31
		} else {
32
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
33
		}
34
	}
35
36
}
37