Skip to content

Commit 1f2bbac

Browse files
committed
Implement stringable
1 parent c0d4daf commit 1f2bbac

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/Model/Distance.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use SoureCode\Bundle\Unit\Model\Length\LengthUnitInterface;
88
use SoureCode\Bundle\Unit\Model\Length\Meter;
99

10-
final class Distance
10+
final class Distance implements \Stringable
1111
{
1212
private LengthUnitInterface $value;
1313

@@ -102,4 +102,9 @@ public function getValue(): LengthUnitInterface
102102
{
103103
return $this->value;
104104
}
105+
106+
public function __toString()
107+
{
108+
return $this->format();
109+
}
105110
}

src/Model/Duration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use SoureCode\Bundle\Unit\Model\Time\Week;
1414
use SoureCode\Bundle\Unit\Model\Time\Year;
1515

16-
final class Duration
16+
final class Duration implements \Stringable
1717
{
1818
/**
1919
* @var array{years: int, months: int, days: int, hours: int, minutes: int, seconds: int}|null
@@ -270,4 +270,9 @@ public function getValue(): TimeUnitInterface
270270
{
271271
return $this->value;
272272
}
273+
274+
public function __toString()
275+
{
276+
return $this->format();
277+
}
273278
}

0 commit comments

Comments
 (0)