DayTrait   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 76
ccs 18
cts 18
cp 1
rs 10
c 1
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A isBeforeToday() 0 4 1
A isBeforeOrIsToday() 0 4 1
A isAfterToday() 0 4 1
A isAfterOrIsToday() 0 4 1
A tomorrow() 0 4 1
A yesterday() 0 4 1
A nextDay() 0 4 1
A previousDay() 0 4 1
A addDay() 0 4 1
1
<?php namespace BestServedCold\PhalueObjects\DateTime\Unit;
2
3
use BestServedCold\PhalueObjects\DateTime\DateTimeTrait;
4
5
/**
6
 * Class DayTrait
7
 *
8
 * @package   BestServedCold\PhalueObjects\DateTime\Unit
9
 * @author    Adam Lewis <[email protected]>
10
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
11
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
12
 * @link      http://bestservedcold.com
13
 * @since     0.0.1-alpha
14
 * @version   0.0.2-alpha
15
 */
16
trait DayTrait
17
{
18
    use DateTimeTrait;
19
20
    /**
21
     * @return bool
22
     */
23 1
    public function isBeforeToday()
24
    {
25 1
        return $this->isBefore(static::now());
26
    }
27
28
    /**
29
     * @return bool
30
     */
31 1
    public function isBeforeOrIsToday()
32
    {
33 1
        return $this->isAfterOrIs(static::now());
34
    }
35
36
    /**
37
     * @return bool
38
     */
39 1
    public function isAfterToday()
40
    {
41 1
        return $this->isAfter(static::now());
42
    }
43
44
    /**
45
     * @return bool
46
     */
47 1
    public function isAfterOrIsToday()
48
    {
49 1
        return $this->isBeforeOrIs(static::now());
50
    }
51
52
    /**
53
     * @return static
54
     */
55 1
    public static function tomorrow()
56
    {
57 1
        return static::now()->nextDay();
58
    }
59
60
    /**
61
     * @return static
62
     */
63 1
    public static function yesterday()
64
    {
65 1
        return static::now()->previousDay();
66
    }
67
68
    /**
69
     * @return static
70
     */
71 1
    public function nextDay()
72
    {
73 1
        return $this->addDay(1);
74
    }
75
76
    /**
77
     * @return static
78
     */
79 1
    public function previousDay()
80
    {
81 1
        return $this->addDay(-1);
82
    }
83
84
    /**
85
     * @return static
86
     */
87 4
    public function addDay($days)
88
    {
89 4
        return static::fromNative($this->native->modify($days.' day'));
90
    }
91
}
92