From 9c2383b1614f7b9a7a40416b54d9bc8063b68172 Mon Sep 17 00:00:00 2001 From: Si Thu Hpyo Date: Mon, 1 Jan 2024 10:37:56 +0630 Subject: [PATCH] fix format --- src/Services/CreditService.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Services/CreditService.php b/src/Services/CreditService.php index 8bdb048..19810ed 100644 --- a/src/Services/CreditService.php +++ b/src/Services/CreditService.php @@ -51,7 +51,7 @@ public function addCreditToHolder( 'meta' => $meta, ]); - if (!$expiresAt) { + if (! $expiresAt) { $credit = $this->addNonExpiringCredit( $holder, $amount, @@ -87,7 +87,7 @@ public function addNonExpiringCredit( ->lockForUpdate() ->first(); - if (!$credit) { + if (! $credit) { $credit = $this->creditModel->newInstance([ 'holder_type' => $holder->getMorphClass(), 'holder_id' => $holder->getKey(), @@ -116,7 +116,7 @@ public function addExpiringCredit( ]); } - public function useCredit( + public function useCreditFromHolder( Model $holder, float $amount, string $name, @@ -124,7 +124,7 @@ public function useCredit( ?array $meta = null, ) { - if (!$this->checkHolderCredit($holder, $amount)) { + if (! $this->checkHolderCredit($holder, $amount)) { throw new \Exception('Insufficient credit'); } @@ -141,7 +141,7 @@ public function useCredit( 'meta' => $meta, ]); - $credits = $this->getRemainingCreditByHolderForUpdate($holder); + $credits = $this->getRemainingCreditFromHolderForUpdate($holder); $remainingAmount = $amount; @@ -192,7 +192,10 @@ public function useCredit( } } - public function getRemainingCreditByHolderForUpdate( + /** + * @return \Illuminate\Support\Collection + */ + public function getRemainingCreditFromHolderForUpdate( Model $holder, ): Collection { return $this->creditModel