Skip to content

Commit 229f303

Browse files
committed
DurationConverterTest coverage increased
1 parent a98c48b commit 229f303

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/SDK/Helper/DurationConverter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,26 @@ public static function toSeconds(string $duration, ?string $format = 'l') : floa
4545

4646
public static function toMinute(string $duration, ?string $format = 'l') : float
4747
{
48-
return self::toSeconds($duration, $format) / 60;
48+
return round(self::toSeconds($duration, $format) / 60, 2);
4949
}
5050

5151
public static function toHour(string $duration, ?string $format = 'l') : float
5252
{
53-
return self::toMinute($duration, $format) / 60;
53+
return round(self::toMinute($duration, $format) / 60, 2);
5454
}
5555

5656
public static function toDay(string $duration, ?string $format = 'l') : float
5757
{
58-
return self::toHour($duration, $format) / 24;
58+
return round(self::toHour($duration, $format) / 24, 2);
5959
}
6060

6161
public static function toMonth(string $duration, ?string $format = 'l') : float
6262
{
63-
return round(self::toDay($duration, $format) / 30, 2);
63+
return round(self::toDay($duration, $format) / 30, 1);
6464
}
6565

6666
public static function toYear(string $duration, ?string $format = 'l') : float
6767
{
68-
return round(self::toDay($duration, $format) / 365, 2);
68+
return round(self::toDay($duration, $format) / 365, 1);
6969
}
7070
}

tests/unit/Helper/DurationConverterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function shouldConvertDurationToSecondsSuccessfully() : void
3535
public function shouldConvertDurationToYearSuccessfully() : void
3636
{
3737
$duration = 'P1Y9M4DT1H5M0S';
38-
$expected = round(1 + 9*30/365 + 4/365 + 1/365/60 + 5/365/60/60, 2);
38+
$expected = round(1 + 9*30/365 + 4/365 + 1/365/60 + 5/365/60/60, 1);
3939
$result = DurationConverter::toYear($duration);
4040
$this->assertEquals($expected, $result);
4141
}
@@ -46,7 +46,7 @@ public function shouldConvertDurationToYearSuccessfully() : void
4646
public function shouldConvertDurationToMonthSuccessfully() : void
4747
{
4848
$duration = 'P0Y9M4DT1H5M0S';
49-
$expected = round( 9 + 4/30 + 1/30/60 + 5/30/60/60, 2);
49+
$expected = round(9 + 4/30 + 1/30/60 + 5/30/60/60, 1);
5050
$result = DurationConverter::toMonth($duration);
5151
$this->assertEquals($expected, $result, 'shouldConvertDurationToMonthSuccessfully');
5252
}

0 commit comments

Comments
 (0)