Year::now()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 Year
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 Year extends Integer implements DateTimeInterface
21
{
22
    use DateTimeTrait;
23
24
    /**
25
     * @param integer $value
26
     */
27 5
    public function __construct($value)
28
    {
29 5
        parent::__construct($value);
30 4
    }
31
32
    /**
33
     * @return static
34
     */
35 1
    public static function now()
36
    {
37 1
        return new static(self::getNowDateTimeFormat('z'));
38
    }
39
40
    /**
41
     * From Native
42
     *
43
     * @param \DateTime $native
44
     * @return DateTimeInterface
45
     */
46 1
    public static function fromNative(\DateTime $native)
47
    {
48 1
        return new static((int) $native->format('z'));
49
    }
50
51
    /**
52
     * From String.
53
     *
54
     * @param  $string
55
     * @return static
56
     */
57 1
    public static function fromString($string)
58
    {
59 1
        return new static((int) $string);
60
    }
61
}
62