Month   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 66
ccs 15
cts 15
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A fromString() 0 4 1
A fromNative() 0 4 1
A getMaximum() 0 4 1
A getMinimum() 0 4 1
A __construct() 0 4 1
A now() 0 4 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\DateTime\Unit\Day;
4
5
use BestServedCold\PhalueObjects\Contract\DateTime as DateTimeInterface;
6
use BestServedCold\PhalueObjects\DateTime\DateTimeTrait;
7
use BestServedCold\PhalueObjects\Mathematical\Integer;
8
9
/**
10
 * Class Month
11
 *
12
 * @package   BestServedCold\PhalueObjects\DateTime\Unit\Day
13
 * @author    Adam Lewis <[email protected]>
14
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
15
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
16
 * @link      http://bestservedcold.com
17
 * @since     0.0.1-alpha
18
 * @version   0.0.2-alpha
19
 */
20
final class Month extends Integer implements DateTimeInterface
21
{
22
    use DateTimeTrait;
23
24
    /**
25
     * @param integer $value
26
     */
27 31
    public function __construct($value)
28
    {
29 31
        parent::__construct($value);
30 30
    }
31
32
    /**
33
     * @return static
34
     */
35 13
    public static function now()
36
    {
37 13
        return new static(self::getNowDateTimeFormat('j'));
38
    }
39
40
    /**
41
     * @return string
42
     */
43 25
    public function __toString()
44
    {
45 25
        return str_pad($this->getValue(), 2, '0', STR_PAD_LEFT);
46
    }
47
48
    /**
49
     * From String.
50
     *
51
     * @param  $string
52
     * @return static
53
     */
54 1
    public static function fromString($string)
55
    {
56 1
        return new static((int) $string);
57
    }
58
59
    /**
60
     * From Native
61
     *
62
     * @param \DateTime $native
63
     * @return DateTimeInterface
64
     */
65 1
    public static function fromNative(\DateTime $native)
66
    {
67 1
        return new static((int) $native->format('j'));
68
    }
69
70
    /**
71
     * @return int
72
     */
73 1
    public function getMaximum()
74
    {
75 1
        return 31;
76
    }
77
78
    /**
79
     * @return int
80
     */
81 1
    public function getMinimum()
82
    {
83 1
        return 1;
84
    }
85
}
86