diff --git a/src/Z38/SwissPayment/IBAN.php b/src/Z38/SwissPayment/IBAN.php index c7472e2..ac1c13e 100644 --- a/src/Z38/SwissPayment/IBAN.php +++ b/src/Z38/SwissPayment/IBAN.php @@ -10,6 +10,9 @@ class IBAN const MAX_LENGTH = 34; const PATTERN = '/^[A-Z]{2,2}[0-9]{2,2}[A-Z0-9]{1,30}$/'; + /** + * @var string + */ protected $iban; /** diff --git a/src/Z38/SwissPayment/Message/CustomerCreditTransfer.php b/src/Z38/SwissPayment/Message/CustomerCreditTransfer.php index 79654db..fc750a4 100644 --- a/src/Z38/SwissPayment/Message/CustomerCreditTransfer.php +++ b/src/Z38/SwissPayment/Message/CustomerCreditTransfer.php @@ -10,9 +10,24 @@ */ class CustomerCreditTransfer extends AbstractMessage { + /** + * @var string + */ protected $id; + + /** + * @var string + */ protected $initiatingParty; + + /** + * @var array + */ protected $payments; + + /** + * @var \DateTime + */ protected $creationTime; /** @@ -23,8 +38,8 @@ class CustomerCreditTransfer extends AbstractMessage */ public function __construct($id, $initiatingParty) { - $this->id = $id; - $this->initiatingParty = $initiatingParty; + $this->id = (string) $id; + $this->initiatingParty = (string) $initiatingParty; $this->payments = array(); $this->creationTime = new \DateTime(); } diff --git a/src/Z38/SwissPayment/Money/Money.php b/src/Z38/SwissPayment/Money/Money.php index dd933a5..318fedf 100644 --- a/src/Z38/SwissPayment/Money/Money.php +++ b/src/Z38/SwissPayment/Money/Money.php @@ -7,6 +7,9 @@ */ abstract class Money { + /** + * @var int + */ protected $cents; /** diff --git a/src/Z38/SwissPayment/PaymentInformation/PaymentInformation.php b/src/Z38/SwissPayment/PaymentInformation/PaymentInformation.php index 9cae218..c6ec2a7 100644 --- a/src/Z38/SwissPayment/PaymentInformation/PaymentInformation.php +++ b/src/Z38/SwissPayment/PaymentInformation/PaymentInformation.php @@ -14,12 +14,39 @@ */ class PaymentInformation { + /** + * @var string + */ protected $id; + + /** + * @var array + */ protected $transactions; + + /** + * @var bool + */ protected $batchBooking; + + /** + * @var \DateTime + */ protected $executionDate; + + /** + * @var string + */ protected $debtorName; + + /** + * @var FinancialInstitutionInterface + */ protected $debtorAgent; + + /** + * @var IBAN + */ protected $debtorIBAN; /** @@ -36,11 +63,11 @@ public function __construct($id, $debtorName, FinancialInstitutionInterface $deb throw new \InvalidArgumentException('The debtor agent must be an instance of BC or BIC.'); } - $this->id = $id; + $this->id = (string) $id; $this->transactions = array(); $this->batchBooking = true; $this->executionDate = new \DateTime(); - $this->debtorName = $debtorName; + $this->debtorName = (string) $debtorName; $this->debtorAgent = $debtorAgent; $this->debtorIBAN = $debtorIBAN; } diff --git a/src/Z38/SwissPayment/PostalAccount.php b/src/Z38/SwissPayment/PostalAccount.php index 153ce35..68cbeaa 100644 --- a/src/Z38/SwissPayment/PostalAccount.php +++ b/src/Z38/SwissPayment/PostalAccount.php @@ -9,8 +9,19 @@ class PostalAccount { const PATTERN = '/^[0-9]{2}-[1-9][0-9]{0,5}-[0-9]$/'; + /** + * @var int + */ protected $prefix; + + /** + * @var int + */ protected $number; + + /** + * @var int + */ protected $checkDigit; /** @@ -31,9 +42,9 @@ public function __construct($postalAccount) throw new \InvalidArgumentException('Postal account number has an invalid prefix.'); } - $this->prefix = $parts[0]; - $this->number = $parts[1]; - $this->checkDigit = $parts[2]; + $this->prefix = (int) $parts[0]; + $this->number = (int) $parts[1]; + $this->checkDigit = (int) $parts[2]; } /** @@ -46,6 +57,13 @@ public function format() return sprintf('%d-%d-%d', $this->prefix, $this->number, $this->checkDigit); } + /** + * Checks whether a given prefix is valid + * + * @param int $prefix The prefix to be checked + * + * @return bool True if the prefix is valid + */ private static function checkPrefix($prefix) { return in_array($prefix, array( diff --git a/src/Z38/SwissPayment/PostalAddress.php b/src/Z38/SwissPayment/PostalAddress.php index bb0214b..f44004f 100644 --- a/src/Z38/SwissPayment/PostalAddress.php +++ b/src/Z38/SwissPayment/PostalAddress.php @@ -7,10 +7,29 @@ */ class PostalAddress { + /** + * @var string + */ protected $street; + + /** + * @var string|null + */ protected $buildingNo; + + /** + * @var string + */ protected $postCode; + + /** + * @var string + */ protected $town; + + /** + * @var string + */ protected $country; /** @@ -24,11 +43,11 @@ class PostalAddress */ public function __construct($street, $buildingNo, $postCode, $town, $country = 'CH') { - $this->street = $street; + $this->street = (string) $street; $this->buildingNo = $buildingNo; - $this->postCode = $postCode; - $this->town = $town; - $this->country = $country; + $this->postCode = (string) $postCode; + $this->town = (string) $town; + $this->country = (string) $country; } /** diff --git a/src/Z38/SwissPayment/TransactionInformation/CreditTransfer.php b/src/Z38/SwissPayment/TransactionInformation/CreditTransfer.php index ba5eaf1..1a50218 100644 --- a/src/Z38/SwissPayment/TransactionInformation/CreditTransfer.php +++ b/src/Z38/SwissPayment/TransactionInformation/CreditTransfer.php @@ -10,11 +10,34 @@ */ abstract class CreditTransfer { + /** + * @var string + */ protected $instructionId; + + /** + * @var string + */ protected $endToEndId; + + /** + * @var string + */ protected $creditorName; + + /** + * @var PostalAddress + */ protected $creditorAddress; + + /** + * @var Money + */ protected $amount; + + /** + * @var string|null + */ protected $remittanceInformation; /** @@ -28,10 +51,10 @@ abstract class CreditTransfer */ public function __construct($instructionId, $endToEndId, Money $amount, $creditorName, PostalAddress $creditorAddress) { - $this->instructionId = $instructionId; - $this->endToEndId = $endToEndId; + $this->instructionId = (string) $instructionId; + $this->endToEndId = (string) $endToEndId; $this->amount = $amount; - $this->creditorName = $creditorName; + $this->creditorName = (string) $creditorName; $this->creditorAddress = $creditorAddress; $this->remittanceInformation = null; } diff --git a/src/Z38/SwissPayment/TransactionInformation/IS1CreditTransfer.php b/src/Z38/SwissPayment/TransactionInformation/IS1CreditTransfer.php index f330034..3f85064 100644 --- a/src/Z38/SwissPayment/TransactionInformation/IS1CreditTransfer.php +++ b/src/Z38/SwissPayment/TransactionInformation/IS1CreditTransfer.php @@ -11,6 +11,9 @@ */ class IS1CreditTransfer extends CreditTransfer { + /** + * @var PostalAccount + */ protected $creditorAccount; /** diff --git a/src/Z38/SwissPayment/TransactionInformation/IS2CreditTransfer.php b/src/Z38/SwissPayment/TransactionInformation/IS2CreditTransfer.php index 49a1e21..3e1b091 100644 --- a/src/Z38/SwissPayment/TransactionInformation/IS2CreditTransfer.php +++ b/src/Z38/SwissPayment/TransactionInformation/IS2CreditTransfer.php @@ -12,8 +12,19 @@ */ class IS2CreditTransfer extends CreditTransfer { + /** + * @var IBAN + */ protected $creditorIBAN; + + /** + * @var string + */ protected $creditorAgentName; + + /** + * @var PostalAccount + */ protected $creditorAgentPostal; /** @@ -27,7 +38,7 @@ public function __construct($instructionId, $endToEndId, Money\CHF $amount, $cre parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress); $this->creditorIBAN = $creditorIBAN; - $this->creditorAgentName = $creditorAgentName; + $this->creditorAgentName = (string) $creditorAgentName; $this->creditorAgentPostal = $creditorAgentPostal; }