Skip to content

Commit

Permalink
php 8.2 improvings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBeycan committed Jan 25, 2024
1 parent ff5a87a commit df98157
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions app/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ class Api extends AbstractApi
private Request $request;

/**
* @var string
* @var string|null
*/
private string $addon;
private ?string $addon;

/**
* @var AbstractTransaction
*/
private AbstractTransaction $model;

/**
* @var string
* @var string|null
*/
private string $hash;
private ?string $hash;

/**
* @var object
Expand Down Expand Up @@ -123,7 +123,7 @@ public function init(): void
$paymentAmount = Services::calculatePaymentAmount(
$this->order->currency,
$this->order->paymentCurrency,
$this->order->amount
floatval($this->order->amount)
);

if (is_null($paymentAmount)) {
Expand Down Expand Up @@ -263,7 +263,7 @@ public function currencyConverter(): void
$paymentAmount = Services::calculatePaymentAmount(
$this->order->currency,
$this->order->paymentCurrency,
$this->order->amount,
floatval($this->order->amount),
$this->network
);

Expand Down
2 changes: 1 addition & 1 deletion app/Models/AbstractTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function search(string $text, array $params = []): array
*/
public function updateStatusByHash(string $hash, string $status): ?bool
{
return $this->update([
return (bool) $this->update([
'status' => $status,
'updatedAt' => date('Y-m-d H:i:s', $this->getUTCTime()->getTimestamp())
], [
Expand Down
4 changes: 2 additions & 2 deletions app/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static function autoInitalize(string $addon, array $data, array $network
$paymentAmount = self::calculatePaymentAmount(
$data['order']['currency'],
(object) $paymentCurrency,
$data['order']['amount']
floatval($data['order']['amount'])
);
} else {
$paymentAmount = 0;
Expand Down Expand Up @@ -494,6 +494,6 @@ public static function toString(float|int $amount, int $decimals): string
$amount = number_format($amount, $decimals, '.', '');
}

return $amount > 1 ? $amount : rtrim($amount, '0');
return strval($amount > 1 ? $amount : rtrim(strval($amount), '0'));
}
}

0 comments on commit df98157

Please sign in to comment.