Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
eidolex committed Jan 1, 2024
1 parent d5e51c8 commit 9c2383b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Services/CreditService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function addCreditToHolder(
'meta' => $meta,
]);

if (!$expiresAt) {
if (! $expiresAt) {
$credit = $this->addNonExpiringCredit(
$holder,
$amount,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -116,15 +116,15 @@ public function addExpiringCredit(
]);
}

public function useCredit(
public function useCreditFromHolder(
Model $holder,
float $amount,
string $name,
?string $description = null,
?array $meta = null,
) {

if (!$this->checkHolderCredit($holder, $amount)) {
if (! $this->checkHolderCredit($holder, $amount)) {
throw new \Exception('Insufficient credit');
}

Expand All @@ -141,7 +141,7 @@ public function useCredit(
'meta' => $meta,
]);

$credits = $this->getRemainingCreditByHolderForUpdate($holder);
$credits = $this->getRemainingCreditFromHolderForUpdate($holder);

$remainingAmount = $amount;

Expand Down Expand Up @@ -192,7 +192,10 @@ public function useCredit(
}
}

public function getRemainingCreditByHolderForUpdate(
/**
* @return \Illuminate\Support\Collection<array-key, Credit>
*/
public function getRemainingCreditFromHolderForUpdate(
Model $holder,
): Collection {
return $this->creditModel
Expand Down

0 comments on commit 9c2383b

Please sign in to comment.