Skip to content

Commit d568ee3

Browse files
HP-2166 Add Bill Usage Interval (#90)
1 parent 0786e14 commit d568ee3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/action/UsageInterval.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,15 @@ public function ratioOfMonth(): float
178178
*/
179179
public function extend(self $other): self
180180
{
181+
$newStart = min($this->start, $other->start);
182+
$newEnd = max($this->end, $other->end);
183+
184+
if ($newStart > $newEnd) {
185+
throw new InvalidArgumentException('Cannot extend intervals: resulting interval would be invalid');
186+
}
181187
return new self(
182-
min($this->start, $other->start),
183-
max($this->end, $other->end),
188+
$newStart,
189+
$newEnd,
184190
);
185191
}
186192
}

src/bill/Bill.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public function getUniqueString(): string
111111

112112
public function getUsageInterval(): UsageInterval
113113
{
114+
return $this->usageInterval;
114115
}
115116

116117
public function calculatePrice()

0 commit comments

Comments
 (0)