Passed
Push — master ( f5fadc...72d313 )
by Christian
02:28
created

BatchTime   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setDay() 0 3 1
A getTime() 0 3 1
A __toString() 0 3 2
A setTime() 0 3 1
A getSeconds() 0 3 2
A getDay() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\Form\Model;
13
14
class BatchTime
15
{
16
    /**
17
     * @var int
18
     */
19
    private $day = 0;
20
21
    /**
22
     * @var \DateTime|null
23
     * */
24
    private $time;
25
26
    public function __toString()
27
    {
28
        return 'Day: '.$this->day.', Time: '.($this->time ? $this->time->format('H:i:s') : '');
29
    }
30
31
    /**
32
     * @return int
33
     */
34
    public function getDay(): int
35
    {
36
        return $this->day ?: 0;
37
    }
38
39
    /**
40
     * @param int $day
41
     */
42
    public function setDay(int $day): void
43
    {
44
        $this->day = $day;
45
    }
46
47
    /**
48
     * @return \DateTime|null
49
     */
50
    public function getTime(): ?\DateTime
51
    {
52
        return $this->time;
53
    }
54
55
    /**
56
     * @param \DateTime $time
57
     */
58
    public function setTime(\DateTime $time): void
59
    {
60
        $this->time = $time;
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getSeconds(): int
67
    {
68
        return $this->getDay() * 86400 + (null !== $this->getTime() ? (int) $this->getTime()->format('U') : 0);
69
    }
70
}
71