diff --git a/src/bill/Bill.php b/src/bill/Bill.php index 6e833f5..8178268 100755 --- a/src/bill/Bill.php +++ b/src/bill/Bill.php @@ -89,7 +89,6 @@ public function __construct( $this->plan = $plan; $this->charges = $charges; $this->state = $state; - $this->setUsageInterval(UsageInterval::wholeMonth($time)); } /** @@ -111,9 +110,18 @@ public function getUniqueString(): string public function getUsageInterval(): UsageInterval { + if ($this->usageInterval === null) { + $this->initializeWholeMonthUsageInterval(); + } + return $this->usageInterval; } + private function initializeWholeMonthUsageInterval(): void + { + $this->setUsageInterval(UsageInterval::wholeMonth($this->time)); + } + public function calculatePrice() { $quantity = $this->quantity->getQuantity();