Passed
Branch scrutinizer (391c16)
by Wanderson
01:43
created

Month   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getName() 0 2 2
A getNameAbbre() 0 6 2
A create() 0 2 1
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
	protected $month;
13
14
	const ABBRE_LENGTH = 3;
15
16
	/**
17
	 * @param int|string $month
18
	 * @return static
19
	 */
20
	public static function create($month) {
21
		return new static($month);
22
	}
23
24
	/** @param int|string $month */
25
	public function __construct($month) {
26
		$this->month = (int) $month;
27
	}
28
29
	/** @return string|false */
30
	public function getName() {
31
		return key_exists($this->month, static::$names) ? static::$names[$this->month] : false;
32
	}
33
34
	/**  @return string|false */
35
	public function getNameAbbre() {
36
		$name = $this->getName();
37
		if ($name) {
38
			return strtoupper(substr($name, 0, static::ABBRE_LENGTH));
39
		} else {
40
			return false;
41
		}
42
	}
43
44
}
45