Week::getMinimum()   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 Week
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 Week extends Integer implements DateTimeInterface
21
{
22
    use DateTimeTrait;
23
24
    /**
25
     * @param integer $value
26
     */
27 6
    public function __construct($value)
28
    {
29 6
        parent::__construct($value);
30 5
    }
31
32
    /**
33
     * @return static
34
     */
35 3
    public static function now()
36
    {
37 3
        return new static(static::getNowDateTimeFormat('N'));
38
    }
39
40
    /**
41
     * From String.
42
     *
43
     * @param  $string
44
     * @return static
45
     */
46 1
    public static function fromString($string)
47
    {
48 1
        return ctype_digit($string)
49 1
            ? new static((int) $string)
50 1
            : self::fromNative(new \DateTime($string));
51
    }
52
53
    /**
54
     * From Native
55
     *
56
     * @param \DateTime $native
57
     * @return DateTimeInterface
58
     */
59 1
    public static function fromNative(\DateTime $native)
60
    {
61 1
        return new static((int) $native->format('N'));
62
    }
63
64
    /**
65
     * @return int
66
     */
67 1
    public function getMaximum()
68
    {
69 1
        return 7;
70
    }
71
72
    /**
73
     * @return int
74
     */
75 1
    public function getMinimum()
76
    {
77 1
        return 1;
78
    }
79
}
80