Completed
Pull Request — master (#30)
by Romain
02:57 queued 31s
created

Value::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
namespace Kerox\Messenger\Model\Data;
3
4
class Value
5
{
6
7
    /**
8
     * @var int|array
9
     */
10
    protected $value;
11
12
    /**
13
     * @var string
14
     */
15
    protected $endTime;
16
17
    /**
18
     * Value constructor.
19
     *
20
     * @param int $value
21
     * @param string $endTime
22
     */
23 3
    public function __construct($value, string $endTime)
24
    {
25 3
        $this->value = $value;
26 3
        $this->endTime = $endTime;
27 3
    }
28
29
    /**
30
     * @return int|array
31
     */
32 2
    public function getValue()
33
    {
34 2
        return $this->value;
35
    }
36
37
    /**
38
     * @param bool $asDateTime
39
     * @return \DateTime|string
40
     */
41 2
    public function getEndTime(bool $asDateTime = true)
42
    {
43 2
        return ($asDateTime) ? \DateTime::createFromFormat(\DateTime::ISO8601, $this->endTime) : $this->endTime;
44
    }
45
}
46