Passed
Push — master ( ae3b0b...26e9e8 )
by Andy
01:17
created

Time::setMinute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Palmtree\Chrono;
4
5
use Palmtree\Chrono\Option\TimePeriods;
6
7
/**
8
 * @method self add(int $value, string $period)
9
 * @method self subtract(int $value, string $period)
10
 */
11
class Time extends DateTime
12
{
13
    public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0): self
14
    {
15
        $this->dateTime->setTime($hour, $minute, $second, $microseconds);
16
17
        return $this;
18
    }
19
20
    public function setHour(int $hour): self
21
    {
22
        return $this->setTime($hour, $this->dateTime->format('i'), $this->dateTime->format('s'), $this->dateTime->format('u'));
0 ignored issues
show
Bug introduced by
$this->dateTime->format('i') of type string is incompatible with the type integer expected by parameter $minute of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
        return $this->setTime($hour, /** @scrutinizer ignore-type */ $this->dateTime->format('i'), $this->dateTime->format('s'), $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('s') of type string is incompatible with the type integer expected by parameter $second of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
        return $this->setTime($hour, $this->dateTime->format('i'), /** @scrutinizer ignore-type */ $this->dateTime->format('s'), $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('u') of type string is incompatible with the type integer expected by parameter $microseconds of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
        return $this->setTime($hour, $this->dateTime->format('i'), $this->dateTime->format('s'), /** @scrutinizer ignore-type */ $this->dateTime->format('u'));
Loading history...
23
    }
24
25
    public function setMinute(int $minute): self
26
    {
27
        return $this->setTime($this->dateTime->format('H'), $minute, $this->dateTime->format('s'), $this->dateTime->format('u'));
0 ignored issues
show
Bug introduced by
$this->dateTime->format('u') of type string is incompatible with the type integer expected by parameter $microseconds of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        return $this->setTime($this->dateTime->format('H'), $minute, $this->dateTime->format('s'), /** @scrutinizer ignore-type */ $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('H') of type string is incompatible with the type integer expected by parameter $hour of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        return $this->setTime(/** @scrutinizer ignore-type */ $this->dateTime->format('H'), $minute, $this->dateTime->format('s'), $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('s') of type string is incompatible with the type integer expected by parameter $second of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        return $this->setTime($this->dateTime->format('H'), $minute, /** @scrutinizer ignore-type */ $this->dateTime->format('s'), $this->dateTime->format('u'));
Loading history...
28
    }
29
30
    public function setSecond(int $second): self
31
    {
32
        return $this->setTime($this->dateTime->format('H'), $this->dateTime->format('i'), $second, $this->dateTime->format('u'));
0 ignored issues
show
Bug introduced by
$this->dateTime->format('H') of type string is incompatible with the type integer expected by parameter $hour of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        return $this->setTime(/** @scrutinizer ignore-type */ $this->dateTime->format('H'), $this->dateTime->format('i'), $second, $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('u') of type string is incompatible with the type integer expected by parameter $microseconds of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        return $this->setTime($this->dateTime->format('H'), $this->dateTime->format('i'), $second, /** @scrutinizer ignore-type */ $this->dateTime->format('u'));
Loading history...
Bug introduced by
$this->dateTime->format('i') of type string is incompatible with the type integer expected by parameter $minute of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        return $this->setTime($this->dateTime->format('H'), /** @scrutinizer ignore-type */ $this->dateTime->format('i'), $second, $this->dateTime->format('u'));
Loading history...
33
    }
34
35
    public function setMicroseconds(int $microseconds): self
36
    {
37
        return $this->setTime($this->dateTime->format('H'), $this->dateTime->format('i'), $this->dateTime->format('s'), $microseconds);
0 ignored issues
show
Bug introduced by
$this->dateTime->format('i') of type string is incompatible with the type integer expected by parameter $minute of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return $this->setTime($this->dateTime->format('H'), /** @scrutinizer ignore-type */ $this->dateTime->format('i'), $this->dateTime->format('s'), $microseconds);
Loading history...
Bug introduced by
$this->dateTime->format('s') of type string is incompatible with the type integer expected by parameter $second of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return $this->setTime($this->dateTime->format('H'), $this->dateTime->format('i'), /** @scrutinizer ignore-type */ $this->dateTime->format('s'), $microseconds);
Loading history...
Bug introduced by
$this->dateTime->format('H') of type string is incompatible with the type integer expected by parameter $hour of Palmtree\Chrono\Time::setTime(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return $this->setTime(/** @scrutinizer ignore-type */ $this->dateTime->format('H'), $this->dateTime->format('i'), $this->dateTime->format('s'), $microseconds);
Loading history...
38
    }
39
40 5
    protected function getFormatFromTimePrecision(?string $precision): string
41
    {
42 5
        return TimePeriods::getDateFormat($precision ?? TimePeriods::SECOND);
43
    }
44
}
45