Skip to content

Commit

Permalink
SP-735 Type Review: PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarzybok-sumoheavy committed Dec 11, 2023
1 parent 30ca2b9 commit aa200c7
Show file tree
Hide file tree
Showing 23 changed files with 1,042 additions and 330 deletions.
54 changes: 11 additions & 43 deletions src/BitPaySDK/Model/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ class Currency
protected ?string $alts = null;
protected ?string $minimum = null;
protected ?bool $sanctioned = null;
protected ?string $decimals = null;
protected array $payoutFields = [];
protected array $settlementMinimum = [];
protected ?int $decimals = null;
protected ?string $chain;

/**
* Currency validation
Expand Down Expand Up @@ -425,61 +424,31 @@ public function setSanctioned(bool $sanctioned): void
/**
* Gets decimal precision
*
* @return string|null decimals
* @return int|null decimals
*/
public function getDecimals(): ?string
public function getDecimals(): ?int
{
return $this->decimals;
}

/**
* Sets decimal precision
*
* @param string $decimals decimals
* @param int|null $decimals decimals
*/
public function setDecimals(string $decimals): void
public function setDecimals(?int $decimals): void
{
$this->decimals = $decimals;
}

/**
* Gets payout fields
*
* @return array the payout fields
*/
public function getPayoutFields(): array
{
return $this->payoutFields;
}

/**
* Sets payout fields
*
* @param array $payoutFields the payout fields
*/
public function setPayoutFields(array $payoutFields): void
public function getChain(): ?string
{
$this->payoutFields = $payoutFields;
return $this->chain;
}

/**
* Gets settlement minimum
*
* @return array the settlement minimum
*/
public function getSettlementMinimum(): array
{
return $this->settlementMinimum;
}

/**
* Sets settlement minimum
*
* @param array $settlementMinimum the settlement minimum
*/
public function setSettlementMinimum(array $settlementMinimum): void
public function setChain(?string $chain): void
{
$this->settlementMinimum = $settlementMinimum;
$this->chain = $chain;
}

/**
Expand All @@ -500,8 +469,7 @@ public function toArray(): array
'minimum' => $this->getMinimum(),
'sanctioned' => $this->getSanctioned(),
'decimals' => $this->getDecimals(),
'payoutFields' => $this->getPayoutFields(),
'settlementMinimum' => $this->getSettlementMinimum(),
'chain' => $this->getChain()
];

foreach ($elements as $key => $value) {
Expand Down
129 changes: 129 additions & 0 deletions src/BitPaySDK/Model/Invoice/BuyerFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php

/**
* Copyright (c) 2019 BitPay
**/

declare(strict_types=1);

namespace BitPaySDK\Model\Invoice;

/**
* @package BitPaySDK\Model\Invoice
* @author BitPay Integrations <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @see https://developer.bitpay.com/reference/notifications-invoices Notifications Invoices
*/
class BuyerFields
{
protected ?string $buyerName = null;
protected ?string $buyerAddress1 = null;
protected ?string $buyerAddress2 = null;
protected ?string $buyerCity = null;
protected ?string $buyerState = null;
protected ?string $buyerZip = null;
protected ?string $buyerCountry = null;
protected ?string $buyerPhone = null;
protected ?bool $buyerNotify = null;
protected ?string $buyerEmail = null;

public function getBuyerName(): ?string
{
return $this->buyerName;
}

public function setBuyerName(?string $buyerName): void
{
$this->buyerName = $buyerName;
}

public function getBuyerAddress1(): ?string
{
return $this->buyerAddress1;
}

public function setBuyerAddress1(?string $buyerAddress1): void
{
$this->buyerAddress1 = $buyerAddress1;
}

public function getBuyerAddress2(): ?string
{
return $this->buyerAddress2;
}

public function setBuyerAddress2(?string $buyerAddress2): void
{
$this->buyerAddress2 = $buyerAddress2;
}

public function getBuyerCity(): ?string
{
return $this->buyerCity;
}

public function setBuyerCity(?string $buyerCity): void
{
$this->buyerCity = $buyerCity;
}

public function getBuyerState(): ?string
{
return $this->buyerState;
}

public function setBuyerState(?string $buyerState): void
{
$this->buyerState = $buyerState;
}

public function getBuyerZip(): ?string
{
return $this->buyerZip;
}

public function setBuyerZip(?string $buyerZip): void
{
$this->buyerZip = $buyerZip;
}

public function getBuyerCountry(): ?string
{
return $this->buyerCountry;
}

public function setBuyerCountry(?string $buyerCountry): void
{
$this->buyerCountry = $buyerCountry;
}

public function getBuyerPhone(): ?string
{
return $this->buyerPhone;
}

public function setBuyerPhone(?string $buyerPhone): void
{
$this->buyerPhone = $buyerPhone;
}

public function getBuyerNotify(): ?bool
{
return $this->buyerNotify;
}

public function setBuyerNotify(?bool $buyerNotify): void
{
$this->buyerNotify = $buyerNotify;
}

public function getBuyerEmail(): ?string
{
return $this->buyerEmail;
}

public function setBuyerEmail(?string $buyerEmail): void
{
$this->buyerEmail = $buyerEmail;
}
}
43 changes: 22 additions & 21 deletions src/BitPaySDK/Model/Invoice/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Invoice
protected ?array $paymentSubtotals = null;
protected ?array $paymentTotals = null;
protected ?array $paymentCodes = null;
protected ?float $acceptanceWindow = null;
protected ?int $acceptanceWindow = null;
protected ?Buyer $buyer = null;
protected ?array $refundAddresses = null;
protected ?string $closeURL = null;
Expand All @@ -60,10 +60,10 @@ class Invoice
protected ?string $status = null;
protected ?bool $lowFeeDetected = null;
protected ?int $invoiceTime = null;
protected ?string $expirationTime = null;
protected ?string $currentTime = null;
protected ?int $expirationTime = null;
protected ?int $currentTime = null;
protected ?array $transactions = null;
protected ?bool $exceptionStatus = null;
protected bool|string|null $exceptionStatus = null;
protected ?int $targetConfirmations = null;
protected ?bool $refundAddressRequestPending = null;
protected ?string $buyerProvidedEmail = null;
Expand Down Expand Up @@ -778,9 +778,9 @@ public function setItemizedDetails(array $itemizedDetails): void
* If not set, invoice will default to the account acceptanceWindow.
* If account acceptanceWindow is not set, invoice will default to 15 minutes (900,000 milliseconds).
*
* @return float|null the acceptance window
* @return int|null the acceptance window
*/
public function getAcceptanceWindow(): ?float
public function getAcceptanceWindow(): ?int
{
return $this->acceptanceWindow;
}
Expand All @@ -792,9 +792,9 @@ public function getAcceptanceWindow(): ?float
* If not set, invoice will default to the account acceptanceWindow.
* If account acceptanceWindow is not set, invoice will default to 15 minutes (900,000 milliseconds).
*
* @param float $acceptanceWindow Number of milliseconds that a user has to pay an invoice before it expire
* @param int $acceptanceWindow Number of milliseconds that a user has to pay an invoice before it expire
*/
public function setAcceptanceWindow(float $acceptanceWindow): void
public function setAcceptanceWindow(int $acceptanceWindow): void
{
$this->acceptanceWindow = $acceptanceWindow;
}
Expand Down Expand Up @@ -960,7 +960,7 @@ public function setUrl(string $url): void
* Instant Payment Notification (IPN) section.
* </a>
*
* @return string|null Invoice status
* @return string|null InvoiceStatus const value
*/
public function getStatus(): ?string
{
Expand All @@ -973,9 +973,10 @@ public function getStatus(): ?string
* Detailed information about invoice status notifications can be found under the
* <a href="https://bitpay.com/api/#notifications-webhooks-instant-payment-notifications-handling">
* Instant Payment Notification (IPN) section.
* Use values from InvoiceStatus const.
* </a>
*
* @param string $status Invoice status
* @param string $status InvoiceStatus const value
*/
public function setStatus(string $status): void
{
Expand Down Expand Up @@ -1031,39 +1032,39 @@ public function setInvoiceTime(int $invoiceTime)
/**
* Gets expirationTime - UNIX time when invoice is last available to be paid, in milliseconds
*
* @return string|null the UNIX time
* @return int|null the UNIX time
*/
public function getExpirationTime(): ?string
public function getExpirationTime(): ?int
{
return $this->expirationTime;
}

/**
* Sets expirationTime - UNIX time when invoice is last available to be paid, in milliseconds
*
* @param string $expirationTime UNIX time when invoice is last available to be paid, in milliseconds
* @param int|null $expirationTime UNIX time when invoice is last available to be paid, in milliseconds
*/
public function setExpirationTime(string $expirationTime): void
public function setExpirationTime(?int $expirationTime): void
{
$this->expirationTime = $expirationTime;
}

/**
* Gets currentTime - UNIX time of API call, in milliseconds
*
* @return string|null UNIX time
* @return int|null UNIX time
*/
public function getCurrentTime(): ?string
public function getCurrentTime(): ?int
{
return $this->currentTime;
}

/**
* Sets currentTime - UNIX time of API call, in milliseconds
*
* @param string $currentTime UNIX time of API call, in milliseconds
* @param int|null $currentTime UNIX time of API call, in milliseconds
*/
public function setCurrentTime(string $currentTime): void
public function setCurrentTime(?int $currentTime): void
{
$this->currentTime = $currentTime;
}
Expand Down Expand Up @@ -1101,9 +1102,9 @@ public function setTransactions(array $transactions): void
* "paidPartial": (string) if the consumer did not send enough funds when paying the invoice.
* "paidOver": (string) if the consumer sent to much funds when paying the invoice.
*
* @return bool|null the exception status
* @return bool|string|null the exception status
*/
public function getExceptionStatus(): ?bool
public function getExceptionStatus(): bool|string|null
{
return $this->exceptionStatus;
}
Expand All @@ -1119,7 +1120,7 @@ public function getExceptionStatus(): ?bool
*
* @param boolean $exceptionStatus this parameter will indicate if the purchaser sent too much or not enough funds
*/
public function setExceptionStatus(bool $exceptionStatus): void
public function setExceptionStatus(bool|string|null $exceptionStatus): void
{
$this->exceptionStatus = $exceptionStatus;
}
Expand Down
Loading

0 comments on commit aa200c7

Please sign in to comment.