Minute   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 75
c 0
b 0
f 0
ccs 17
cts 17
cp 1
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSeconds() 0 4 1
A now() 0 4 1
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
1
<?php
2
3
namespace BestServedCold\PhalueObjects\DateTime\Unit;
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 Minute
11
 *
12
 * @package   BestServedCold\PhalueObjects\DateTime\Unit
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 Minute extends Integer implements DateTimeInterface
21
{
22
    use DateTimeTrait;
23
24
    /**
25
     * @param integer $value
26
     */
27 22
    public function __construct($value)
28
    {
29 22
        parent::__construct($value);
30 22
    }
31
32
    /**
33
     * @return static
34
     */
35 17
    public function getSeconds()
36
    {
37 17
        return $this->multiply(new Integer(60));
38
    }
39
40
    /**
41
     * @return static
42
     */
43 10
    public static function now()
44
    {
45 10
        return new static(self::getNowDateTimeFormat('i'));
46
    }
47
48
    /**
49
     * @return string
50
     */
51 12
    public function __toString()
52
    {
53 12
        return str_pad($this->getValue(), 2, '0', STR_PAD_LEFT);
54
    }
55
56
    /**
57
     * From String.
58
     *
59
     * @param  $string
60
     *
61
     * @return static
62
     */
63 1
    public static function fromString($string)
64
    {
65 1
        return new static((int) $string);
66
    }
67
68
    /**
69
     * From Native
70
     *
71
     * @param \DateTime $native
72
     * @return DateTimeInterface
73
     */
74 1
    public static function fromNative(\DateTime $native)
75
    {
76 1
        return new static((int) $native->format('i'));
77
    }
78
79
    /**
80
     * @return int
81
     */
82 1
    public function getMaximum()
83
    {
84 1
        return 59;
85
    }
86
87
    /**
88
     * @return int
89
     */
90 1
    public function getMinimum()
91
    {
92 1
        return 0;
93
    }
94
}
95