From bbbcb2b6693fade0ec26c3d0cc89d1bd0abc086f Mon Sep 17 00:00:00 2001 From: Hugo Bailey Date: Wed, 10 Feb 2016 19:56:01 +0100 Subject: [PATCH] Fix merge conflicts and add PSR-2 compliance #59 --- MangoPay/ApiCardPreAuthorizations.php | 15 ++- MangoPay/ApiCardRegistrations.php | 15 ++- MangoPay/ApiCards.php | 22 ++-- MangoPay/ApiEvents.php | 9 +- MangoPay/ApiHooks.php | 18 +-- MangoPay/ApiKycDocuments.php | 12 +- MangoPay/ApiPayIns.php | 38 +++--- MangoPay/ApiPayOuts.php | 19 +-- MangoPay/ApiRefunds.php | 9 +- MangoPay/ApiTransfers.php | 13 +- MangoPay/ApiUsers.php | 119 ++++++++++-------- MangoPay/ApiWallets.php | 16 ++- MangoPay/Autoloader.php | 2 +- MangoPay/BankAccount.php | 20 +-- MangoPay/BankAccountDetails.php | 4 +- MangoPay/BankAccountDetailsCA.php | 12 +- MangoPay/BankAccountDetailsGB.php | 8 +- MangoPay/BankAccountDetailsIBAN.php | 8 +- MangoPay/BankAccountDetailsOTHER.php | 16 +-- MangoPay/BankAccountDetailsUS.php | 8 +- MangoPay/Card.php | 22 ++-- MangoPay/CardPreAuthorization.php | 58 ++++----- MangoPay/CardRegistration.php | 39 +++--- MangoPay/CardValidity.php | 5 +- MangoPay/Client.php | 10 +- MangoPay/Event.php | 8 +- MangoPay/EventType.php | 5 +- MangoPay/FilterBase.php | 9 +- MangoPay/FilterEvents.php | 4 +- MangoPay/FilterTransactions.php | 9 +- MangoPay/Hook.php | 12 +- MangoPay/KeyValueArray.php | 4 +- MangoPay/KycDocument.php | 8 +- MangoPay/KycDocumentStatus.php | 5 +- MangoPay/KycDocumentType.php | 5 +- MangoPay/KycPage.php | 9 +- MangoPay/Libraries/ApiBase.php | 112 +++++++++-------- MangoPay/Libraries/ApiClients.php | 10 +- MangoPay/Libraries/ApiOAuth.php | 9 +- MangoPay/Libraries/AuthenticationHelper.php | 41 +++--- .../Libraries/AuthorizationTokenManager.php | 22 ++-- MangoPay/Libraries/Configuration.php | 16 +-- MangoPay/Libraries/DefaultStorageStrategy.php | 43 ++++--- MangoPay/Libraries/Dto.php | 21 +++- MangoPay/Libraries/EntityBase.php | 10 +- MangoPay/Libraries/Error.php | 7 +- MangoPay/Libraries/Exception.php | 3 +- MangoPay/Libraries/IStorageStrategy.php | 10 +- MangoPay/Libraries/Logs.php | 10 +- MangoPay/Libraries/OAuthToken.php | 12 +- MangoPay/Libraries/RequestType.php | 5 +- MangoPay/Libraries/ResponseException.php | 15 +-- MangoPay/Libraries/RestTool.php | 89 ++++++------- MangoPay/Libraries/UrlTool.php | 31 ++--- MangoPay/MangoPayApi.php | 33 ++--- MangoPay/Money.php | 4 +- MangoPay/Pagination.php | 13 +- MangoPay/PayIn.php | 24 ++-- MangoPay/PayInExecutionDetails.php | 4 +- MangoPay/PayInExecutionDetailsDirect.php | 14 +-- MangoPay/PayInExecutionDetailsWeb.php | 24 ++-- MangoPay/PayInPaymentDetails.php | 4 +- MangoPay/PayInPaymentDetailsBankWire.php | 11 +- MangoPay/PayInPaymentDetailsCard.php | 6 +- MangoPay/PayInPaymentDetailsDirectDebit.php | 4 +- MangoPay/PayInPaymentDetailsPreAuthorized.php | 6 +- MangoPay/PayInTemplateURLOptions.php | 10 +- MangoPay/PayOut.php | 20 +-- MangoPay/PayOutPaymentDetails.php | 4 +- MangoPay/PayOutPaymentDetailsBankWire.php | 6 +- MangoPay/PersonType.php | 5 +- MangoPay/Refund.php | 14 +-- MangoPay/RefundReasonDetails.php | 6 +- MangoPay/SortDirection.php | 5 +- MangoPay/Sorting.php | 25 ++-- MangoPay/TemporaryImmediatePayIn.php | 8 +- MangoPay/TemporaryPaymentCard.php | 18 +-- MangoPay/Transaction.php | 22 ++-- MangoPay/Transfer.php | 8 +- MangoPay/User.php | 18 +-- MangoPay/UserLegal.php | 64 +++++----- MangoPay/UserNatural.php | 38 +++--- MangoPay/Wallet.php | 18 +-- 83 files changed, 823 insertions(+), 674 deletions(-) diff --git a/MangoPay/ApiCardPreAuthorizations.php b/MangoPay/ApiCardPreAuthorizations.php index 6477eeaa..56364733 100644 --- a/MangoPay/ApiCardPreAuthorizations.php +++ b/MangoPay/ApiCardPreAuthorizations.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for pre-authorization process */ -class ApiCardPreAuthorizations extends Libraries\ApiBase { - +class ApiCardPreAuthorizations extends Libraries\ApiBase +{ /** * Create new pre-authorization object * @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to create * @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API */ - public function Create($cardPreAuthorization, $idempotencyKey = null) { + public function Create($cardPreAuthorization, $idempotencyKey = null) + { return $this->CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization', null, null, $idempotencyKey); } @@ -20,7 +21,8 @@ public function Create($cardPreAuthorization, $idempotencyKey = null) { * @param int $cardPreAuthorizationId PreAuthorization identifier * @return \MangoPay\CardPreAuthorization Card registration object returned from API */ - public function Get($cardPreAuthorizationId) { + public function Get($cardPreAuthorizationId) + { return $this->GetObject('preauthorization_get', $cardPreAuthorizationId, '\MangoPay\CardPreAuthorization'); } @@ -29,7 +31,8 @@ public function Get($cardPreAuthorizationId) { * @param \MangoPay\CardPreAuthorization $preAuthorization PreAuthorization object to save * @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API */ - public function Update($cardPreAuthorization) { + public function Update($cardPreAuthorization) + { return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiCardRegistrations.php b/MangoPay/ApiCardRegistrations.php index b7eae7e5..9acaf6b4 100644 --- a/MangoPay/ApiCardRegistrations.php +++ b/MangoPay/ApiCardRegistrations.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for card registrations */ -class ApiCardRegistrations extends Libraries\ApiBase { - +class ApiCardRegistrations extends Libraries\ApiBase +{ /** * Create new card registration * @param \MangoPay\CardRegistration $cardRegistration Card registration object to create * @return \MangoPay\CardRegistration Card registration object returned from API */ - public function Create($cardRegistration, $idempotencyKey = null) { + public function Create($cardRegistration, $idempotencyKey = null) + { return $this->CreateObject('cardregistration_create', $cardRegistration, '\MangoPay\CardRegistration', null, null, $idempotencyKey); } @@ -20,7 +21,8 @@ public function Create($cardRegistration, $idempotencyKey = null) { * @param int $cardRegistrationId Card Registration identifier * @return \MangoPay\CardRegistration Card registration object returned from API */ - public function Get($cardRegistrationId) { + public function Get($cardRegistrationId) + { return $this->GetObject('cardregistration_get', $cardRegistrationId, '\MangoPay\CardRegistration'); } @@ -29,7 +31,8 @@ public function Get($cardRegistrationId) { * @param \MangoPay\CardRegistration $cardRegistration Card registration object to save * @return \MangoPay\CardRegistration Card registration object returned from API */ - public function Update($cardRegistration) { + public function Update($cardRegistration) + { return $this->SaveObject('cardregistration_save', $cardRegistration, '\MangoPay\CardRegistration'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiCards.php b/MangoPay/ApiCards.php index ab996a88..051aff14 100644 --- a/MangoPay/ApiCards.php +++ b/MangoPay/ApiCards.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for cards */ -class ApiCards extends Libraries\ApiBase { - +class ApiCards extends Libraries\ApiBase +{ /** * Get card * @param int $cardId Card identifier * @return \MangoPay\Card object returned from API */ - public function Get($cardId) { + public function Get($cardId) + { return $this->GetObject('card_get', $cardId, '\MangoPay\Card'); } @@ -20,7 +21,8 @@ public function Get($cardId) { * @param \MangoPay\Card $card Card object to save * @return \MangoPay\Card Card object returned from API */ - public function Update($card) { + public function Update($card) + { return $this->SaveObject('card_save', $card, '\MangoPay\Card'); } @@ -28,12 +30,13 @@ public function Update($card) { * WARNING!! * It's temporary entity and it will be removed in the future. * Please, contact with support before using these features or if you have any questions. - * + * * Create new temporary payment card * @param \MangoPay\TemporaryPaymentCard $paymentCard Payment card object to create * @return \MangoPay\TemporaryPaymentCard Card registration object returned from API */ - public function CreateTemporaryPaymentCard($paymentCard, $idempotencyKey = null) { + public function CreateTemporaryPaymentCard($paymentCard, $idempotencyKey = null) + { return $this->CreateObject('temp_paymentcards_create', $paymentCard, '\MangoPay\TemporaryPaymentCard', null, null, $idempotencyKey); } @@ -41,12 +44,13 @@ public function CreateTemporaryPaymentCard($paymentCard, $idempotencyKey = null) * WARNING!! * It's temporary entity and it will be removed in the future. * Please, contact with support before using these features or if you have any questions. - * + * * Get temporary payment card * @param string $paymentCardId Card identifier * @return \MangoPay\TemporaryPaymentCard object returned from API */ - public function GetTemporaryPaymentCard($paymentCardId) { + public function GetTemporaryPaymentCard($paymentCardId) + { return $this->GetObject('temp_paymentcards_get', $paymentCardId, '\MangoPay\TemporaryPaymentCard'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiEvents.php b/MangoPay/ApiEvents.php index 28c26a42..6259edad 100644 --- a/MangoPay/ApiEvents.php +++ b/MangoPay/ApiEvents.php @@ -4,17 +4,18 @@ /** * Class to management MangoPay API for cards */ -class ApiEvents extends Libraries\ApiBase { - +class ApiEvents extends Libraries\ApiBase +{ /** * Get events * @param \MangoPay\Pagination $pagination Pagination object * @param \MangoPay\FilterEvents $filter Object to filter data * @param \MangoPay\Sorting $sorting Object to sorting data - * + * * @return \MangoPay\Event[] Events list */ - public function GetAll(& $pagination = null, $filter = null, $sorting = null) { + public function GetAll(& $pagination = null, $filter = null, $sorting = null) + { return $this->GetList('events_all', $pagination, '\MangoPay\Event', null, $filter, $sorting); } } diff --git a/MangoPay/ApiHooks.php b/MangoPay/ApiHooks.php index 440fa0ea..36c600a0 100644 --- a/MangoPay/ApiHooks.php +++ b/MangoPay/ApiHooks.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for hooks and notifications */ -class ApiHooks extends Libraries\ApiBase { - +class ApiHooks extends Libraries\ApiBase +{ /** * Create new hook * @param Hook $hook * @return \MangoPay\Hook Hook object returned from API */ - public function Create($hook, $idempotencyKey = null) { + public function Create($hook, $idempotencyKey = null) + { return $this->CreateObject('hooks_create', $hook, '\MangoPay\Hook', null, null, $idempotencyKey); } @@ -20,7 +21,8 @@ public function Create($hook, $idempotencyKey = null) { * @param type $hookId Hook identifier * @return \MangoPay\Hook Wallet object returned from API */ - public function Get($hookId) { + public function Get($hookId) + { return $this->GetObject('hooks_get', $hookId, '\MangoPay\Hook'); } @@ -29,7 +31,8 @@ public function Get($hookId) { * @param type $hook Hook object to save * @return \MangoPay\Hook Hook object returned from API */ - public function Update($hook) { + public function Update($hook) + { return $this->SaveObject('hooks_save', $hook, '\MangoPay\Hook'); } @@ -38,7 +41,8 @@ public function Update($hook) { * @param \MangoPay\Pagination $pagination Pagination object * @return \MangoPay\Hook[] Array with objects returned from API */ - public function GetAll(& $pagination = null) { + public function GetAll(& $pagination = null) + { return $this->GetList('hooks_all', $pagination, '\MangoPay\Hook'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiKycDocuments.php b/MangoPay/ApiKycDocuments.php index 24c3d48b..43e9f6a4 100644 --- a/MangoPay/ApiKycDocuments.php +++ b/MangoPay/ApiKycDocuments.php @@ -4,8 +4,8 @@ /** * Class to management MangoPay API for KYC document list */ -class ApiKycDocuments extends Libraries\ApiBase { - +class ApiKycDocuments extends Libraries\ApiBase +{ /** * Get all KYC documents * @param \MangoPay\Pagination $pagination Pagination object @@ -13,7 +13,8 @@ class ApiKycDocuments extends Libraries\ApiBase { * @param \MangoPay\FilterKycDocuments $filter Object to filter data * @return \MangoPay\KycDocument[] Array with objects returned from API */ - public function GetAll(& $pagination = null, $sorting = null, $filter = null) { + public function GetAll(& $pagination = null, $sorting = null, $filter = null) + { return $this->GetList('kyc_documents_all', $pagination, '\MangoPay\KycDocument', null, $filter, $sorting); } @@ -22,7 +23,8 @@ public function GetAll(& $pagination = null, $sorting = null, $filter = null) { * @param string $kycDocumentId Document identifier * @return \MangoPay\KycDocument Document returned from API */ - public function Get($kycDocumentId) { + public function Get($kycDocumentId) + { return $this->GetObject('kyc_documents_get_alt', $kycDocumentId, '\MangoPay\KycDocument'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiPayIns.php b/MangoPay/ApiPayIns.php index be9ed1a1..8226b9c5 100644 --- a/MangoPay/ApiPayIns.php +++ b/MangoPay/ApiPayIns.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for pay-ins */ -class ApiPayIns extends Libraries\ApiBase { - +class ApiPayIns extends Libraries\ApiBase +{ /** * Create new pay-in object * @param \MangoPay\PayIn $payIn \MangoPay\PayIn object * @return \MangoPay\PayIn Object returned from API */ - public function Create($payIn, $idempotencyKey = null) { + public function Create($payIn, $idempotencyKey = null) + { $paymentKey = $this->GetPaymentKey($payIn); $executionKey = $this->GetExecutionKey($payIn); return $this->CreateObject('payins_' . $paymentKey . '-' . $executionKey . '_create', $payIn, '\MangoPay\PayIn', null, null, $idempotencyKey); @@ -22,7 +23,8 @@ public function Create($payIn, $idempotencyKey = null) { * @param $payInId Pay-in identifier * @return \MangoPay\PayIn Object returned from API */ - public function Get($payInId) { + public function Get($payInId) + { return $this->GetObject('payins_get', $payInId, '\MangoPay\PayIn'); } @@ -32,7 +34,8 @@ public function Get($payInId) { * @param \MangoPay\Refund $refund Refund object to create * @return \MangoPay\Refund Object returned by REST API */ - public function CreateRefund($payInId, $refund, $idempotencyKey = null) { + public function CreateRefund($payInId, $refund, $idempotencyKey = null) + { return $this->CreateObject('payins_createrefunds', $refund, '\MangoPay\Refund', $payInId, null, $idempotencyKey); } @@ -40,30 +43,33 @@ public function CreateRefund($payInId, $refund, $idempotencyKey = null) { * WARNING!! * It's temporary entity and it will be removed in the future. * Please, contact with support before using these features or if you have any questions. - * + * * Create new temporary immediate pay-in * @param \MangoPay\TemporaryImmediatePayIn $immediatePayIn Immediate pay-in object to create * @return \MangoPay\TemporaryImmediatePayIn Immediate pay-in object returned from API */ - public function CreateTemporaryImmediatePayIn($immediatePayIn, $idempotencyKey = null) { + public function CreateTemporaryImmediatePayIn($immediatePayIn, $idempotencyKey = null) + { return $this->CreateObject('temp_immediatepayins_create', $immediatePayIn, '\MangoPay\TemporaryImmediatePayIn', null, null, $idempotencyKey); } - private function GetPaymentKey($payIn) { - - if (!isset($payIn->PaymentDetails) || !is_object($payIn->PaymentDetails)) - throw new Libraries\Exception ('Payment is not defined or it is not object type'); + private function GetPaymentKey($payIn) + { + if (!isset($payIn->PaymentDetails) || !is_object($payIn->PaymentDetails)) { + throw new Libraries\Exception('Payment is not defined or it is not object type'); + } $className = str_replace('MangoPay\\PayInPaymentDetails', '', get_class($payIn->PaymentDetails)); return strtolower($className); } - private function GetExecutionKey($payIn) { - - if (!isset($payIn->ExecutionDetails) || !is_object($payIn->ExecutionDetails)) - throw new Libraries\Exception ('Execution is not defined or it is not object type'); + private function GetExecutionKey($payIn) + { + if (!isset($payIn->ExecutionDetails) || !is_object($payIn->ExecutionDetails)) { + throw new Libraries\Exception('Execution is not defined or it is not object type'); + } $className = str_replace('MangoPay\\PayInExecutionDetails', '', get_class($payIn->ExecutionDetails)); return strtolower($className); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiPayOuts.php b/MangoPay/ApiPayOuts.php index 32458d09..1717be5e 100644 --- a/MangoPay/ApiPayOuts.php +++ b/MangoPay/ApiPayOuts.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for pay-outs */ -class ApiPayOuts extends Libraries\ApiBase { - +class ApiPayOuts extends Libraries\ApiBase +{ /** * Create new pay-out * @param PayOut $payOut * @return \MangoPay\PayOut Object returned from API */ - public function Create($payOut, $idempotencyKey = null) { + public function Create($payOut, $idempotencyKey = null) + { $paymentKey = $this->GetPaymentKey($payOut); return $this->CreateObject('payouts_' . $paymentKey . '_create', $payOut, '\MangoPay\PayOut', null, null, $idempotencyKey); } @@ -21,16 +22,18 @@ public function Create($payOut, $idempotencyKey = null) { * @param $payOutId PayOut identifier * @return \MangoPay\PayOut Object returned from API */ - public function Get($payOutId) { + public function Get($payOutId) + { return $this->GetObject('payouts_get', $payOutId, '\MangoPay\PayOut'); } - private function GetPaymentKey($payOut) { - - if (!isset($payOut->MeanOfPaymentDetails) || !is_object($payOut->MeanOfPaymentDetails)) + private function GetPaymentKey($payOut) + { + if (!isset($payOut->MeanOfPaymentDetails) || !is_object($payOut->MeanOfPaymentDetails)) { throw new Libraries\Exception('Mean of payment is not defined or it is not object type'); + } $className = str_replace('MangoPay\\PayOutPaymentDetails', '', get_class($payOut->MeanOfPaymentDetails)); return strtolower($className); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiRefunds.php b/MangoPay/ApiRefunds.php index 49e9b1bc..b860aa40 100644 --- a/MangoPay/ApiRefunds.php +++ b/MangoPay/ApiRefunds.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for refunds */ -class ApiRefunds extends Libraries\ApiBase { - +class ApiRefunds extends Libraries\ApiBase +{ /** * Get refund object * @param string $refundId Refund Id * @return \MangoPay\Refund Refund object returned from API */ - public function Get($refundId) { + public function Get($refundId) + { return $this->GetObject('refunds_get', $refundId, '\MangoPay\Refund'); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiTransfers.php b/MangoPay/ApiTransfers.php index dd66e284..892e9b3e 100644 --- a/MangoPay/ApiTransfers.php +++ b/MangoPay/ApiTransfers.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for transfers */ -class ApiTransfers extends Libraries\ApiBase { - +class ApiTransfers extends Libraries\ApiBase +{ /** * Create new transfer * @param \MangoPay\Transfer $transfer * @return \MangoPay\Transfer Transfer object returned from API */ - public function Create($transfer, $idempotencyKey = null) { + public function Create($transfer, $idempotencyKey = null) + { return $this->CreateObject('transfers_create', $transfer, '\MangoPay\Transfer', null, null, $idempotencyKey); } @@ -20,7 +21,8 @@ public function Create($transfer, $idempotencyKey = null) { * @param type $transferId Transfer identifier * @return \MangoPay\Transfer Transfer object returned from API */ - public function Get($transfer) { + public function Get($transfer) + { return $this->GetObject('transfers_get', $transfer, '\MangoPay\Transfer'); } @@ -30,7 +32,8 @@ public function Get($transfer) { * @param \MangoPay\Refund $refund Refund object to create * @return \MangoPay\Refund Object returned by REST API */ - public function CreateRefund($transferId, $refund, $idempotencyKey = null) { + public function CreateRefund($transferId, $refund, $idempotencyKey = null) + { return $this->CreateObject('transfers_createrefunds', $refund, '\MangoPay\Refund', $transferId, null, $idempotencyKey); } } diff --git a/MangoPay/ApiUsers.php b/MangoPay/ApiUsers.php index ff695257..d131b42b 100644 --- a/MangoPay/ApiUsers.php +++ b/MangoPay/ApiUsers.php @@ -8,23 +8,24 @@ * Class ApiUsers * @package MangoPay */ -class ApiUsers extends Libraries\ApiBase { - +class ApiUsers extends Libraries\ApiBase +{ /** * Create a new user * @param UserLegal/UserNatural $user * @return UserLegal/UserNatural User object returned from API * @throws Libraries\Exception If occur Wrong entity class for user */ - public function Create($user, $idempotencyKey = null) { - + public function Create($user, $idempotencyKey = null) + { $className = get_class($user); - if ($className == 'MangoPay\UserNatural') + if ($className == 'MangoPay\UserNatural') { $methodKey = 'users_createnaturals'; - elseif ($className == 'MangoPay\UserLegal') + } elseif ($className == 'MangoPay\UserLegal') { $methodKey = 'users_createlegals'; - else + } else { throw new Libraries\Exception('Wrong entity class for user'); + } $response = $this->CreateObject($methodKey, $user, null, null, null, $idempotencyKey); return $this->GetUserResponse($response); @@ -36,7 +37,8 @@ public function Create($user, $idempotencyKey = null) { * @param \MangoPay\Sorting $sorting Object to sorting data * @return array Array with users */ - public function GetAll(& $pagination = null, $sorting = null) { + public function GetAll(& $pagination = null, $sorting = null) + { $usersList = $this->GetList('users_all', $pagination, null, null, null, $sorting); $users = array(); @@ -53,8 +55,8 @@ public function GetAll(& $pagination = null, $sorting = null) { * @param Int|GUID $userId User identifier * @return UserLegal | UserNatural User object returned from API */ - public function Get($userId) { - + public function Get($userId) + { $response = $this->GetObject('users_get', $userId); return $this->GetUserResponse($response); } @@ -64,8 +66,8 @@ public function Get($userId) { * @param Int|GUID $userId User identifier * @return UserLegal|UserNatural User object returned from API */ - public function GetNatural($userId) { - + public function GetNatural($userId) + { $response = $this->GetObject('users_getnaturals', $userId); return $this->GetUserResponse($response); } @@ -75,8 +77,8 @@ public function GetNatural($userId) { * @param Int|GUID $userId User identifier * @return UserLegal|UserNatural User object returned from API */ - public function GetLegal($userId) { - + public function GetLegal($userId) + { $response = $this->GetObject('users_getlegals', $userId); return $this->GetUserResponse($response); } @@ -87,18 +89,19 @@ public function GetLegal($userId) { * @return UserLegal|UserNatural User object returned from API * @throws Libraries\Exception If occur Wrong entity class for user */ - public function Update($user) { - + public function Update($user) + { $className = get_class($user); - if ($className == 'MangoPay\UserNatural') + if ($className == 'MangoPay\UserNatural') { $methodKey = 'users_savenaturals'; - elseif ($className == 'MangoPay\UserLegal') + } elseif ($className == 'MangoPay\UserLegal') { $methodKey = 'users_savelegals'; - else + } else { throw new Libraries\Exception('Wrong entity class for user'); + } $response = $this->SaveObject($methodKey, $user); - return $this->GetUserResponse($response); + return $this->GetUserResponse($response); } /** @@ -107,7 +110,8 @@ public function Update($user) { * @param \MangoPay\BankAccount $bankAccount Entity of bank account object * @return \MangoPay\BankAccount Create bank account object */ - public function CreateBankAccount($userId, $bankAccount, $idempotencyKey = null) { + public function CreateBankAccount($userId, $bankAccount, $idempotencyKey = null) + { $type = $this->GetBankAccountType($bankAccount); return $this->CreateObject('users_createbankaccounts_' . $type, $bankAccount, '\MangoPay\BankAccount', $userId, null, $idempotencyKey); } @@ -117,10 +121,11 @@ public function CreateBankAccount($userId, $bankAccount, $idempotencyKey = null) * @param int $userId User Id * @param \MangoPay\Pagination $pagination Pagination object * @param \MangoPay\Sorting $sorting Object to sorting data - * + * * @return array Array with bank account entities - */ - public function GetBankAccounts($userId, & $pagination = null, $sorting = null) { + */ + public function GetBankAccounts($userId, & $pagination = null, $sorting = null) + { return $this->GetList('users_allbankaccount', $pagination, 'MangoPay\BankAccount', $userId, null, $sorting); } @@ -128,10 +133,11 @@ public function GetBankAccounts($userId, & $pagination = null, $sorting = null) * Get bank account for user * @param int $userId User Id * @param int $bankAccountId Bank account Id - * + * * @return \MangoPay\BankAccount Entity of bank account object */ - public function GetBankAccount($userId, $bankAccountId) { + public function GetBankAccount($userId, $bankAccountId) + { return $this->GetObject('users_getbankaccount', $userId, 'MangoPay\BankAccount', $bankAccountId); } @@ -140,10 +146,11 @@ public function GetBankAccount($userId, $bankAccountId) { * @param int $userId User Id * @param \MangoPay\Pagination $pagination Pagination object * @param \MangoPay\Sorting $sorting Object to sorting data - * + * * @return \MangoPay\Wallet[] Array with objects returned from API */ - public function GetWallets($userId, & $pagination = null, $sorting = null) { + public function GetWallets($userId, & $pagination = null, $sorting = null) + { return $this->GetList('users_allwallets', $pagination, 'MangoPay\Wallet', $userId, null, $sorting); } @@ -153,10 +160,11 @@ public function GetWallets($userId, & $pagination = null, $sorting = null) { * @param \MangoPay\Pagination $pagination Pagination object * @param \MangoPay\FilterTransactions $filter Object to filter data * @param \MangoPay\Sorting $sorting Object to sorting data - * + * * @return \MangoPay\Transaction[] Transactions for user returned from API */ - public function GetTransactions($userId, & $pagination = null, $filter = null, $sorting = null) { + public function GetTransactions($userId, & $pagination = null, $filter = null, $sorting = null) + { return $this->GetList('users_alltransactions', $pagination, '\MangoPay\Transaction', $userId, $filter, $sorting); } @@ -165,10 +173,11 @@ public function GetTransactions($userId, & $pagination = null, $filter = null, $ * @param int $userId User Id * @param \MangoPay\Pagination $pagination Pagination object * @param \MangoPay\Sorting $sorting Object to sorting data - * + * * @return \MangoPay\Card[] Cards for user returned from API */ - public function GetCards($userId, & $pagination = null, $sorting = null) { + public function GetCards($userId, & $pagination = null, $sorting = null) + { return $this->GetList('users_allcards', $pagination, '\MangoPay\Card', $userId, null, $sorting); } @@ -178,7 +187,8 @@ public function GetCards($userId, & $pagination = null, $sorting = null) { * @param \MangoPay\KycDocument $kycDocument * @return \MangoPay\KycDocument Document returned from API */ - public function CreateKycDocument($userId, $kycDocument, $idempotencyKey = null) { + public function CreateKycDocument($userId, $kycDocument, $idempotencyKey = null) + { return $this->CreateObject('kyc_documents_create', $kycDocument, '\MangoPay\KycDocument', $userId, null, $idempotencyKey); } @@ -191,7 +201,8 @@ public function CreateKycDocument($userId, $kycDocument, $idempotencyKey = null) * * @return array Array with KYC documents entities */ - public function GetKycDocuments($userId, & $pagination = null, $sorting = null, $filter = null) { + public function GetKycDocuments($userId, & $pagination = null, $sorting = null, $filter = null) + { return $this->GetList('users_allkycdocuments', $pagination, 'MangoPay\KycDocument', $userId, $filter, $sorting); } @@ -201,7 +212,8 @@ public function GetKycDocuments($userId, & $pagination = null, $sorting = null, * @param string $kycDocumentId Document identifier * @return \MangoPay\KycDocument Document returned from API */ - public function GetKycDocument($userId, $kycDocumentId) { + public function GetKycDocument($userId, $kycDocumentId) + { return $this->GetObject('kyc_documents_get', $userId, '\MangoPay\KycDocument', $kycDocumentId); } @@ -211,7 +223,8 @@ public function GetKycDocument($userId, $kycDocumentId) { * @param \MangoPay\KycDocument $kycDocument Document to save * @return \MangoPay\KycDocument Document returned from API */ - public function UpdateKycDocument($userId, $kycDocument) { + public function UpdateKycDocument($userId, $kycDocument) + { return $this->SaveObject('kyc_documents_save', $kycDocument, '\MangoPay\KycDocument', $userId); } @@ -222,13 +235,15 @@ public function UpdateKycDocument($userId, $kycDocument) { * @param \MangoPay\KycPage $kycPage KYC Page * @throws \MangoPay\Libraries\Exception */ - public function CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey = null) { + public function CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey = null) + { try{ $this->CreateObject('kyc_page_create', $kycPage, null, $userId, $kycDocumentId, $idempotencyKey); } catch (\MangoPay\Libraries\ResponseException $exc) { - if ($exc->getCode() != 204) + if ($exc->getCode() != 204) { throw $exc; + } } } @@ -239,24 +254,27 @@ public function CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey * @param string $file File path * @throws \MangoPay\Libraries\Exception */ - public function CreateKycPageFromFile($userId, $kycDocumentId, $file, $idempotencyKey = null) { - + public function CreateKycPageFromFile($userId, $kycDocumentId, $file, $idempotencyKey = null) + { $filePath = $file; if (is_array($file)) { $filePath = $file['tmp_name']; } - if (empty($filePath)) + if (empty($filePath)) { throw new \MangoPay\Libraries\Exception('Path of file cannot be empty'); + } - if (!file_exists($filePath)) + if (!file_exists($filePath)) { throw new \MangoPay\Libraries\Exception('File not exist'); + } $kycPage = new \MangoPay\KycPage(); $kycPage->File = base64_encode(file_get_contents($filePath)); - if (empty($kycPage->File)) + if (empty($kycPage->File)) { throw new \MangoPay\Libraries\Exception('Content of the file cannot be empty'); + } $this->CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey); } @@ -265,12 +283,11 @@ public function CreateKycPageFromFile($userId, $kycDocumentId, $file, $idempoten * Get correct user object * @param object $response Response from API * @return UserLegal|UserNatural User object returned from API - * @throws \MangoPay\Libraries\Exception If occur unexpected response from API + * @throws \MangoPay\Libraries\Exception If occur unexpected response from API */ - private function GetUserResponse($response) { - + private function GetUserResponse($response) + { if (isset($response->PersonType)) { - switch ($response->PersonType) { case PersonType::Natural: return $this->CastResponseToEntity($response, '\MangoPay\UserNatural'); @@ -278,16 +295,16 @@ private function GetUserResponse($response) { return $this->CastResponseToEntity($response, '\MangoPay\UserLegal'); default: throw new Libraries\Exception('Unexpected response. Wrong PersonType value'); - } + } } else { throw new Libraries\Exception('Unexpected response. Missing PersonType property'); } } - private function GetBankAccountType($bankAccount) { - + private function GetBankAccountType($bankAccount) + { if (!isset($bankAccount->Details) || !is_object($bankAccount->Details)) { - throw new Libraries\Exception ('Details is not defined or it is not object type'); + throw new Libraries\Exception('Details is not defined or it is not object type'); } $className = str_replace('MangoPay\\BankAccountDetails', '', get_class($bankAccount->Details)); diff --git a/MangoPay/ApiWallets.php b/MangoPay/ApiWallets.php index ee26b571..874e6bf6 100644 --- a/MangoPay/ApiWallets.php +++ b/MangoPay/ApiWallets.php @@ -4,14 +4,15 @@ /** * Class to management MangoPay API for wallets */ -class ApiWallets extends Libraries\ApiBase { - +class ApiWallets extends Libraries\ApiBase +{ /** * Create new wallet * @param Wallet $wallet * @return \MangoPay\Wallet Wallet object returned from API */ - public function Create($wallet, $idempotencyKey = null) { + public function Create($wallet, $idempotencyKey = null) + { return $this->CreateObject('wallets_create', $wallet, '\MangoPay\Wallet', null, null, $idempotencyKey); } @@ -20,7 +21,8 @@ public function Create($wallet, $idempotencyKey = null) { * @param int $walletId Wallet identifier * @return \MangoPay\Wallet Wallet object returned from API */ - public function Get($walletId) { + public function Get($walletId) + { return $this->GetObject('wallets_get', $walletId, '\MangoPay\Wallet'); } @@ -29,7 +31,8 @@ public function Get($walletId) { * @param Wallet $wallet Wallet object to save * @return \MangoPay\Wallet Wallet object returned from API */ - public function Update($wallet) { + public function Update($wallet) + { return $this->SaveObject('wallets_save', $wallet, '\MangoPay\Wallet'); } @@ -41,7 +44,8 @@ public function Update($wallet) { * @param \MangoPay\Sorting $sorting Object to sorting data * @return \MangoPay\Transaction[] Transactions for wallet returned from API */ - public function GetTransactions($walletId, & $pagination = null, $filter = null, $sorting = null) { + public function GetTransactions($walletId, & $pagination = null, $filter = null, $sorting = null) + { return $this->GetList('wallets_alltransactions', $pagination, '\MangoPay\Transaction', $walletId, $filter, $sorting); } } diff --git a/MangoPay/Autoloader.php b/MangoPay/Autoloader.php index 2bba93e0..c65f74b0 100644 --- a/MangoPay/Autoloader.php +++ b/MangoPay/Autoloader.php @@ -27,4 +27,4 @@ if (file_exists($file)) { require $file; } -}); \ No newline at end of file +}); diff --git a/MangoPay/BankAccount.php b/MangoPay/BankAccount.php index e1b04b92..bc40035b 100644 --- a/MangoPay/BankAccount.php +++ b/MangoPay/BankAccount.php @@ -4,8 +4,8 @@ /** * Bank Account entity */ -class BankAccount extends Libraries\EntityBase { - +class BankAccount extends Libraries\EntityBase +{ /** * User identifier * @var LeetchiId @@ -14,13 +14,13 @@ class BankAccount extends Libraries\EntityBase { /** * Type of bank account - * @var string + * @var string */ public $Type; /** * Owner name - * @var string + * @var string */ public $OwnerName; @@ -32,7 +32,7 @@ class BankAccount extends Libraries\EntityBase { /** * One of BankAccountDetails implementations, depending on $Type - * @var object + * @var object */ public $Details; @@ -52,7 +52,8 @@ public function GetSubObjects() { * Get array with mapping which property depends on other property * @return array */ - public function GetDependsObjects() { + public function GetDependsObjects() + { return array( 'Type' => array( '_property_name' => 'Details', @@ -69,10 +70,11 @@ public function GetDependsObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'UserId' ); - array_push( $properties, 'Type' ); + array_push($properties, 'UserId'); + array_push($properties, 'Type'); return $properties; } } diff --git a/MangoPay/BankAccountDetails.php b/MangoPay/BankAccountDetails.php index 8ed7fab4..88752683 100644 --- a/MangoPay/BankAccountDetails.php +++ b/MangoPay/BankAccountDetails.php @@ -4,4 +4,6 @@ /** * Marker interface for classes with details option in BankAccount entity */ -interface BankAccountDetails { } \ No newline at end of file +interface BankAccountDetails +{ +} diff --git a/MangoPay/BankAccountDetailsCA.php b/MangoPay/BankAccountDetailsCA.php index bd8a0f41..c2cc16fc 100644 --- a/MangoPay/BankAccountDetailsCA.php +++ b/MangoPay/BankAccountDetailsCA.php @@ -4,8 +4,8 @@ /** * Class represents CA bank account type for in BankAccount entity */ -class BankAccountDetailsCA extends Libraries\Dto implements BankAccountDetails { - +class BankAccountDetailsCA extends Libraries\Dto implements BankAccountDetails +{ /** * Bank name * @var string @@ -14,19 +14,19 @@ class BankAccountDetailsCA extends Libraries\Dto implements BankAccountDetails { /** * Institution number - * @var string + * @var string */ public $InstitutionNumber; /** * Branch code - * @var string + * @var string */ public $BranchCode; /** * Account number - * @var string + * @var string */ public $AccountNumber; -} \ No newline at end of file +} diff --git a/MangoPay/BankAccountDetailsGB.php b/MangoPay/BankAccountDetailsGB.php index 22d344a5..fdf5693a 100644 --- a/MangoPay/BankAccountDetailsGB.php +++ b/MangoPay/BankAccountDetailsGB.php @@ -4,8 +4,8 @@ /** * Class represents GB bank account type for in BankAccount entity */ -class BankAccountDetailsGB extends Libraries\Dto implements BankAccountDetails { - +class BankAccountDetailsGB extends Libraries\Dto implements BankAccountDetails +{ /** * Account number * @var string @@ -14,7 +14,7 @@ class BankAccountDetailsGB extends Libraries\Dto implements BankAccountDetails { /** * Sort code - * @var string + * @var string */ public $SortCode; -} \ No newline at end of file +} diff --git a/MangoPay/BankAccountDetailsIBAN.php b/MangoPay/BankAccountDetailsIBAN.php index 134b4c33..b9f1e8dc 100644 --- a/MangoPay/BankAccountDetailsIBAN.php +++ b/MangoPay/BankAccountDetailsIBAN.php @@ -4,8 +4,8 @@ /** * Class represents IBAN bank account type for in BankAccount entity */ -class BankAccountDetailsIBAN extends Libraries\Dto implements BankAccountDetails { - +class BankAccountDetailsIBAN extends Libraries\Dto implements BankAccountDetails +{ /** * IBAN number * @var string @@ -14,7 +14,7 @@ class BankAccountDetailsIBAN extends Libraries\Dto implements BankAccountDetails /** * BIC - * @var string + * @var string */ public $BIC; -} \ No newline at end of file +} diff --git a/MangoPay/BankAccountDetailsOTHER.php b/MangoPay/BankAccountDetailsOTHER.php index fcf3ef06..3134f166 100644 --- a/MangoPay/BankAccountDetailsOTHER.php +++ b/MangoPay/BankAccountDetailsOTHER.php @@ -4,18 +4,18 @@ /** * Class represents OTHER bank account type for in BankAccount entity */ -class BankAccountDetailsOTHER extends Libraries\Dto implements BankAccountDetails { - +class BankAccountDetailsOTHER extends Libraries\Dto implements BankAccountDetails +{ /** - * Type + * Type * @var string */ public $Type; /** - * The Country associate to the BankAccount, + * The Country associate to the BankAccount, * ISO 3166-1 alpha-2 format is expected - * @var string + * @var string */ public $Country; @@ -26,8 +26,8 @@ class BankAccountDetailsOTHER extends Libraries\Dto implements BankAccountDetail public $BIC; /** - * Account number - * @var string + * Account number + * @var string */ public $AccountNumber; -} \ No newline at end of file +} diff --git a/MangoPay/BankAccountDetailsUS.php b/MangoPay/BankAccountDetailsUS.php index b5437c5b..e20fcaf1 100644 --- a/MangoPay/BankAccountDetailsUS.php +++ b/MangoPay/BankAccountDetailsUS.php @@ -4,8 +4,8 @@ /** * Class represents US bank account type for in BankAccount entity */ -class BankAccountDetailsUS extends Libraries\Dto implements BankAccountDetails { - +class BankAccountDetailsUS extends Libraries\Dto implements BankAccountDetails +{ /** * Account number * @var string @@ -14,13 +14,13 @@ class BankAccountDetailsUS extends Libraries\Dto implements BankAccountDetails { /** * ABA - * @var string + * @var string */ public $ABA; /** * DepositAccountType { CHECKING, SAVINGS } - * @var string + * @var string */ public $DepositAccountType; } diff --git a/MangoPay/Card.php b/MangoPay/Card.php index b2b5e765..64bcb3f6 100644 --- a/MangoPay/Card.php +++ b/MangoPay/Card.php @@ -4,8 +4,8 @@ /** * Card entity */ -class Card extends Libraries\EntityBase { - +class Card extends Libraries\EntityBase +{ /** * Expiration date * @var string @@ -14,37 +14,37 @@ class Card extends Libraries\EntityBase { /** * Alias - * @var string + * @var string */ public $Alias; /** * CardProvider - * @var string + * @var string */ public $CardProvider; /** * UserId - * @var string + * @var string */ public $UserId; /** * Card type - * @var string + * @var string */ public $CardType; /** * Product - * @var string + * @var string */ public $Product ; /** * Bank code - * @var string + * @var string */ public $BankCode; @@ -56,19 +56,19 @@ class Card extends Libraries\EntityBase { /** * Active - * @var bool + * @var bool */ public $Active; /** * Currency - * @var string + * @var string */ public $Currency; /** * Validity - * @var \MangoPay\CardValidity + * @var \MangoPay\CardValidity */ public $Validity; } diff --git a/MangoPay/CardPreAuthorization.php b/MangoPay/CardPreAuthorization.php index 01b15a23..163df8ac 100644 --- a/MangoPay/CardPreAuthorization.php +++ b/MangoPay/CardPreAuthorization.php @@ -4,8 +4,8 @@ /** * Pre-authorization entity */ -class CardPreAuthorization extends Libraries\EntityBase { - +class CardPreAuthorization extends Libraries\EntityBase +{ /** * The user Id of the author of the pre-authorization * @var string @@ -13,8 +13,8 @@ class CardPreAuthorization extends Libraries\EntityBase { public $AuthorId; /** - * It represents the amount debited on the bank account - * of the Author.DebitedFunds = Fees + CreditedFunds + * It represents the amount debited on the bank account + * of the Author.DebitedFunds = Fees + CreditedFunds * (amount received on wallet) * @var \MangoPay\Money */ @@ -29,92 +29,93 @@ class CardPreAuthorization extends Libraries\EntityBase { /** * The status of the payment after the PreAuthorization: * WAITING, CANCELED, EXPIRED, VALIDATED - * @var string + * @var string */ public $PaymentStatus; /** * The PreAuthorization result code - * @var string + * @var string */ public $ResultCode; /** * The PreAuthorization result Message explaining the result code - * @var string + * @var string */ public $ResultMessage; /** - * How the PreAuthorization has been executed. + * How the PreAuthorization has been executed. * Only on value for now: CARD - * @var string + * @var string */ public $ExecutionType; /** - * The SecureMode correspond to '3D secure' for CB Visa and MasterCard - * or 'Amex Safe Key' for American Express. + * The SecureMode correspond to '3D secure' for CB Visa and MasterCard + * or 'Amex Safe Key' for American Express. * This field lets you activate it manually. - * @var string + * @var string */ public $SecureMode; /** * The ID of the registered card (Got through CardRegistration object) - * @var string + * @var string */ public $CardId; /** * Boolean. The value is 'true' if the SecureMode was used - * @var string + * @var string */ public $SecureModeNeeded; /** - * This is the URL where to redirect users to proceed + * This is the URL where to redirect users to proceed * to 3D secure validation - * @var string + * @var string */ public $SecureModeRedirectURL; /** - * This is the URL where users are automatically redirected + * This is the URL where users are automatically redirected * after 3D secure validation (if activated) - * @var string + * @var string */ public $SecureModeReturnURL; /** * The date when the payment is processed - * @var Timestamp + * @var Timestamp */ public $ExpirationDate; /** * The date when the payment was authorized - * @var Timestamp + * @var Timestamp */ public $AuthorizationDate; /** * The type of pre-authorization ("CARD" is the only acceptable value at present - * @var string + * @var string */ public $PaymentType; /** * The Id of the associated PayIn - * @var string + * @var string */ public $PayInId; /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ - public function GetSubObjects() { + public function GetSubObjects() + { return array( 'DebitedFunds' => '\MangoPay\Money' ); @@ -124,11 +125,12 @@ public function GetSubObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'Status' ); - array_push( $properties, 'ResultCode' ); - array_push( $properties, 'ResultMessage' ); + array_push($properties, 'Status'); + array_push($properties, 'ResultCode'); + array_push($properties, 'ResultMessage'); return $properties; } diff --git a/MangoPay/CardRegistration.php b/MangoPay/CardRegistration.php index 3b348c95..2ff3ceb7 100644 --- a/MangoPay/CardRegistration.php +++ b/MangoPay/CardRegistration.php @@ -4,8 +4,8 @@ /** * CardRegistration entity */ -class CardRegistration extends Libraries\EntityBase { - +class CardRegistration extends Libraries\EntityBase +{ /** * User Id * @var string @@ -20,55 +20,55 @@ class CardRegistration extends Libraries\EntityBase { /** * Access key - * @var string + * @var string */ public $AccessKey; /** * Preregistration data - * @var string + * @var string */ public $PreregistrationData; /** * Card registration URL - * @var string + * @var string */ public $CardRegistrationURL; /** * Card Id - * @var string + * @var string */ public $CardId; /** * Card registration data - * @var string + * @var string */ public $RegistrationData; /** * The result code of the object - * @var string + * @var string */ public $ResultCode; /** * The message explaning the result code - * @var string + * @var string */ public $ResultMessage; /** * Currency - * @var string + * @var string */ public $Currency; /** * Status - * @var string + * @var string */ public $Status; @@ -76,15 +76,16 @@ class CardRegistration extends Libraries\EntityBase { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'AccessKey' ); - array_push( $properties, 'PreregistrationData' ); - array_push( $properties, 'CardRegistrationURL' ); - array_push( $properties, 'CardId' ); - array_push( $properties, 'ResultCode' ); - array_push( $properties, 'ResultMessage' ); - array_push( $properties, 'Status' ); + array_push($properties, 'AccessKey'); + array_push($properties, 'PreregistrationData'); + array_push($properties, 'CardRegistrationURL'); + array_push($properties, 'CardId'); + array_push($properties, 'ResultCode'); + array_push($properties, 'ResultMessage'); + array_push($properties, 'Status'); return $properties; } } diff --git a/MangoPay/CardValidity.php b/MangoPay/CardValidity.php index 617fe7dd..4d6541af 100644 --- a/MangoPay/CardValidity.php +++ b/MangoPay/CardValidity.php @@ -1,8 +1,9 @@ array( '/api/clients/', RequestType::POST ), @@ -123,7 +123,7 @@ protected function getLogger() 'disputes_repudiation_create_settlement' => array( '/repudiations/%s/settlementtransfer', RequestType::POST), 'disputes_repudiation_get_settlement' => array( '/settlements/%s', RequestType::GET), - // These are temporary functions and WILL be removed in the future. + // These are temporary functions and WILL be removed in the future. // Please, contact with support before using these features or if you have any questions. 'temp_paymentcards_create' => array( '/temp/paymentcards', RequestType::POST ), 'temp_paymentcards_get' => array( '/temp/paymentcards/%s', RequestType::GET ), @@ -134,25 +134,28 @@ protected function getLogger() * Constructor * @param \MangoPay\MangoPayApi Root/parent instance that holds the OAuthToken and Configuration instance */ - function __construct($root) { + public function __construct($root) + { $this->_root = $root; } /** * Get URL for REST Mango Pay API * @param string $key Key with data - * @return string + * @return string */ - protected function GetRequestUrl($key){ + protected function GetRequestUrl($key) + { return $this->_methods[$key][0]; } /** * Get request type for REST Mango Pay API * @param string $key Key with data - * @return RequestType + * @return RequestType */ - protected function GetRequestType($key){ + protected function GetRequestType($key) + { return $this->_methods[$key][1]; } @@ -164,24 +167,28 @@ protected function GetRequestType($key){ * @param int $entityId Entity identifier * @return object Response data */ - protected function CreateObject($methodKey, $entity, $responseClassName = null, $entityId = null, $subEntityId = null, $idempotencyKey = null) { + protected function CreateObject($methodKey, $entity, $responseClassName = null, $entityId = null, $subEntityId = null, $idempotencyKey = null) + { - if (is_null($entityId)) + if (is_null($entityId)) { $urlMethod = $this->GetRequestUrl($methodKey); - elseif (is_null($subEntityId)) + } elseif (is_null($subEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId); - else + } else { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId, $subEntityId); + } $requestData = null; - if (!is_null($entity)) + if (!is_null($entity)) { $requestData = $this->BuildRequestData($entity); + } $rest = new RestTool(true, $this->_root); $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), $requestData, $idempotencyKey); - if (!is_null($responseClassName)) + if (!is_null($responseClassName)) { return $this->CastResponseToEntity($response, $responseClassName); + } return $response; } @@ -194,15 +201,16 @@ protected function CreateObject($methodKey, $entity, $responseClassName = null, * @param int $secondEntityId Entity identifier for second entity * @return object Response data */ - protected function GetObject($methodKey, $entityId, $responseClassName = null, $secondEntityId = null) { - + protected function GetObject($methodKey, $entityId, $responseClassName = null, $secondEntityId = null) + { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId, $secondEntityId); $rest = new RestTool(true, $this->_root); $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey)); - if (!is_null($responseClassName)) + if (!is_null($responseClassName)) { return $this->CastResponseToEntity($response, $responseClassName); + } return $response; } @@ -217,8 +225,8 @@ protected function GetObject($methodKey, $entityId, $responseClassName = null, $ * @param \MangoPay\Sorting $sorting Object to sorting data * @return object Response data */ - protected function GetList($methodKey, & $pagination, $responseClassName = null, $entityId = null, $filter = null, $sorting = null) { - + protected function GetList($methodKey, & $pagination, $responseClassName = null, $entityId = null, $filter = null, $sorting = null) + { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId); if (is_null($pagination) || !is_object($pagination) || get_class($pagination) != 'MangoPay\Pagination') { @@ -227,19 +235,22 @@ protected function GetList($methodKey, & $pagination, $responseClassName = null, $rest = new RestTool(true, $this->_root); $additionalUrlParams = array(); - if (!is_null($filter)) + if (!is_null($filter)) { $additionalUrlParams["filter"] = $filter; - if (!is_null($sorting)){ - if (!is_a($sorting, "\MangoPay\Sorting")) + } + if (!is_null($sorting)) { + if (!is_a($sorting, "\MangoPay\Sorting")) { throw new Exception('Wrong type of sorting object'); + } $additionalUrlParams["sort"] = $sorting->GetSortParameter(); } $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), null, null, $pagination, $additionalUrlParams); - if (!is_null($responseClassName)) + if (!is_null($responseClassName)) { return $this->CastResponseToEntity($response, $responseClassName); + } return $response; } @@ -251,20 +262,22 @@ protected function GetList($methodKey, & $pagination, $responseClassName = null, * @param object $responseClassName Name of entity class from response * @return object Response data */ - protected function SaveObject($methodKey, $entity, $responseClassName = null, $secondEntityId = null) { - - if (is_null($secondEntityId)) + protected function SaveObject($methodKey, $entity, $responseClassName = null, $secondEntityId = null) + { + if (is_null($secondEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entity->Id); - else + } else { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $secondEntityId, $entity->Id); + } $requestData = $this->BuildRequestData($entity); $rest = new RestTool(true, $this->_root); $response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), $requestData); - if (!is_null($responseClassName)) + if (!is_null($responseClassName)) { return $this->CastResponseToEntity($response, $responseClassName); + } return $response; } @@ -278,7 +291,6 @@ protected function SaveObject($methodKey, $entity, $responseClassName = null, $s protected function CastResponseToEntity($response, $entityClassName, $asDependentObject = false) { if (is_array($response)) { - $list = array(); foreach ($response as $responseObject) { array_push($list, $this->CastResponseToEntity($responseObject, $entityClassName)); @@ -301,23 +313,22 @@ protected function CastResponseToEntity($response, $entityClassName, $asDependen $dependsObjects = $entity->GetDependsObjects(); foreach ($responseProperties as $responseProperty) { - $responseProperty->setAccessible(true); $name = $responseProperty->getName(); $value = $responseProperty->getValue($response); if ($entityReflection->hasProperty($name)) { - $entityProperty = $entityReflection->getProperty($name); $entityProperty->setAccessible(true); // is sub object? if (isset($subObjects[$name])) { - if (is_null($value)) + if (is_null($value)) { $object = null; - else + } else { $object = $this->CastResponseToEntity($value, $subObjects[$name]); + } $entityProperty->setValue($entity, $object); } else { @@ -333,14 +344,13 @@ protected function CastResponseToEntity($response, $entityClassName, $asDependen } } else { if ($asDependentObject || !empty($dependsObjects)) { + continue; + } else { + /* UNCOMMENT THE LINE BELOW TO ENABLE RESTRICTIVE REFLECTION MODE */ + //throw new Exception('Cannot cast response to entity object. Missing property ' . $name .' in entity ' . $entityClassName); + continue; } - else { - /* UNCOMMENT THE LINE BELOW TO ENABLE RESTRICTIVE REFLECTION MODE */ - //throw new Exception('Cannot cast response to entity object. Missing property ' . $name .' in entity ' . $entityClassName); - - continue; - } } } @@ -350,17 +360,17 @@ protected function CastResponseToEntity($response, $entityClassName, $asDependen /** * Get array with request data * @param object $entity Entity object to send as request data - * @return array + * @return array */ - protected function BuildRequestData($entity) { - + protected function BuildRequestData($entity) + { $entityProperties = get_object_vars($entity); $blackList = $entity->GetReadOnlyProperties(); $requestData = array(); foreach ($entityProperties as $propertyName => $propertyValue) { - - if (in_array($propertyName, $blackList)) + if (in_array($propertyName, $blackList)) { continue; + } if ($this->CanReadSubRequestData($entity, $propertyName)) { $subRequestData = $this->BuildRequestData($propertyValue); @@ -368,8 +378,9 @@ protected function BuildRequestData($entity) { $requestData[$key] = $value; } } else { - if (isset($propertyValue)) + if (isset($propertyValue)) { $requestData[$propertyName] = $propertyValue; + } } } @@ -379,8 +390,9 @@ protected function BuildRequestData($entity) { return $requestData; } - private function CanReadSubRequestData($entity, $propertyName) { - if (get_class($entity) == 'MangoPay\PayIn' && + private function CanReadSubRequestData($entity, $propertyName) + { + if (get_class($entity) == 'MangoPay\PayIn' && ($propertyName == 'PaymentDetails' || $propertyName == 'ExecutionDetails')) { return true; } @@ -389,10 +401,10 @@ private function CanReadSubRequestData($entity, $propertyName) { return true; } - if (get_class($entity) == 'MangoPay\BankAccount' && $propertyName == 'Details' ) { + if (get_class($entity) == 'MangoPay\BankAccount' && $propertyName == 'Details') { return true; } return false; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/ApiClients.php b/MangoPay/Libraries/ApiClients.php index 1b4081c7..ca641287 100644 --- a/MangoPay/Libraries/ApiClients.php +++ b/MangoPay/Libraries/ApiClients.php @@ -4,8 +4,8 @@ /** * Class to management MangoPay API for users */ -class ApiClients extends ApiBase { - +class ApiClients extends ApiBase +{ /** * Get client data for Basic Access Authentication * @param string $clientId Client identifier @@ -13,8 +13,8 @@ class ApiClients extends ApiBase { * @param string $clientEmail Client's email * @return \MangoPay\Client Client object */ - public function Create($clientId, $clientName, $clientEmail) { - + public function Create($clientId, $clientName, $clientEmail) + { $urlMethod = $this->GetRequestUrl('authentication_base'); $requestType = $this->GetRequestType('authentication_base'); $requestData = array( @@ -27,4 +27,4 @@ public function Create($clientId, $clientName, $clientEmail) { $response = $rest->Request($urlMethod, $requestType, $requestData); return $this->CastResponseToEntity($response, '\MangoPay\Client'); } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/ApiOAuth.php b/MangoPay/Libraries/ApiOAuth.php index 0180b284..ef4c8f4e 100644 --- a/MangoPay/Libraries/ApiOAuth.php +++ b/MangoPay/Libraries/ApiOAuth.php @@ -4,13 +4,14 @@ /** * Authentication manager */ -class ApiOAuth extends ApiBase { - +class ApiOAuth extends ApiBase +{ /** * Get token information to OAuth Authentication * @return \MangoPay\Libraries\OAuthToken OAuthToken object with token information */ - public function CreateToken() { + public function CreateToken() + { $urlMethod = $this->GetRequestUrl('authentication_oauth'); $requestType = $this->GetRequestType('authentication_oauth'); $requestData = array( @@ -27,4 +28,4 @@ public function CreateToken() { $response = $rest->Request($urlMethod, $requestType, $requestData); return $this->CastResponseToEntity($response, '\MangoPay\Libraries\OAuthToken'); } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/AuthenticationHelper.php b/MangoPay/Libraries/AuthenticationHelper.php index 0466a5a3..f6bc5697 100644 --- a/MangoPay/Libraries/AuthenticationHelper.php +++ b/MangoPay/Libraries/AuthenticationHelper.php @@ -1,8 +1,8 @@ _root = $root; } @@ -21,7 +22,8 @@ function __construct($root) { * Get HTTP header value with authorization string * @return string Authorization string */ - public function GetHttpHeaderKey(){ + public function GetHttpHeaderKey() + { return $this->GetHttpHeaderStrong(); } @@ -30,12 +32,15 @@ public function GetHttpHeaderKey(){ * @return string * @throws \MangoPay\Libraries\Exception If MangoPay_ClientId or MangoPay_ClientPassword is not defined */ - public function GetHttpHeaderBasicKey() { - if (is_null($this->_root->Config->ClientId) || strlen($this->_root->Config->ClientId) == 0) - throw new Exception ('MangoPayApi.Config.ClientId is not set.'); + public function GetHttpHeaderBasicKey() + { + if (is_null($this->_root->Config->ClientId) || strlen($this->_root->Config->ClientId) == 0) { + throw new Exception('MangoPayApi.Config.ClientId is not set.'); + } - if (is_null($this->_root->Config->ClientPassword) || strlen($this->_root->Config->ClientPassword) == 0) - throw new Exception ('MangoPayApi.Config.ClientPassword is not set.'); + if (is_null($this->_root->Config->ClientPassword) || strlen($this->_root->Config->ClientPassword) == 0) { + throw new Exception('MangoPayApi.Config.ClientPassword is not set.'); + } $signature = $this->_root->Config->ClientId . ':' . $this->_root->Config->ClientPassword; return base64_encode($signature); @@ -43,27 +48,29 @@ public function GetHttpHeaderBasicKey() { /** * Get HTTP header value with authorization string for basic authentication - * + * * @return string Value for HTTP header with authentication string * @throws \MangoPay\Libraries\Exception If required constants are not defined. */ - private function GetHttpHeaderBasic() { - + private function GetHttpHeaderBasic() + { return 'Authorization: Basic ' . $this->GetHttpHeaderBasicKey(); } /** * Get HTTP header value with authorization string for strong authentication - * + * * @return string Value for HTTP header with authentication string * @throws \MangoPay\Libraries\Exception If OAuth token is not created (or is invalid) for strong authentication. */ - private function GetHttpHeaderStrong() { + private function GetHttpHeaderStrong() + { $token = $this->_root->OAuthTokenManager->GetToken(); - if (is_null($token) || !isset($token->access_token) || !isset($token->token_type)) - throw new Exception ('OAuth token is not created (or is invalid) for strong authentication'); + if (is_null($token) || !isset($token->access_token) || !isset($token->token_type)) { + throw new Exception('OAuth token is not created (or is invalid) for strong authentication'); + } return 'Authorization: ' . $token->token_type . ' ' . $token->access_token; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/AuthorizationTokenManager.php b/MangoPay/Libraries/AuthorizationTokenManager.php index 04e53af0..e5f17292 100644 --- a/MangoPay/Libraries/AuthorizationTokenManager.php +++ b/MangoPay/Libraries/AuthorizationTokenManager.php @@ -4,15 +4,16 @@ /** * Authorization token manager */ -class AuthorizationTokenManager extends ApiBase { - +class AuthorizationTokenManager extends ApiBase +{ /** * Storage object * @var \MangoPay\IStorageStrategy */ private $_storageStrategy; - function __construct($root) { + public function __construct($root) + { $this->_root = $root; $this->RegisterCustomStorageStrategy(new DefaultStorageStrategy($this->_root->Config)); @@ -24,7 +25,8 @@ function __construct($root) { * If currently stored token is expired, this method creates a new one. * @return \MangoPay\Libraries\OAuthToken Valid OAuthToken instance. */ - public function GetToken() { + public function GetToken() + { $token = $this->_storageStrategy->get(); if (is_null($token) || $token->IsExpired()) { @@ -39,18 +41,20 @@ public function GetToken() { * storage strategy implementation. * @param \MangoPay\Libraries\OAuthToken $token Token instance to be stored. */ - public function StoreToken($token) { + public function StoreToken($token) + { $this->_storageStrategy->Store($token); } /** * Registers custom storage strategy implementation. - * By default, the DefaultStorageStrategy instance is used. - * There is no need to explicitly call this method until some more complex + * By default, the DefaultStorageStrategy instance is used. + * There is no need to explicitly call this method until some more complex * storage implementation is needed. * @param \MangoPay\IStorageStrategy $customStorageStrategy IStorageStrategy interface implementation. */ - public function RegisterCustomStorageStrategy($customStorageStrategy) { + public function RegisterCustomStorageStrategy($customStorageStrategy) + { $this->_storageStrategy = $customStorageStrategy; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/Configuration.php b/MangoPay/Libraries/Configuration.php index bef40ff0..b4007857 100644 --- a/MangoPay/Libraries/Configuration.php +++ b/MangoPay/Libraries/Configuration.php @@ -4,23 +4,23 @@ /** * Configuration settings */ -class Configuration { - +class Configuration +{ /** * Client Id * @var string */ public $ClientId; - + /** * Client password - * @var string + * @var string */ public $ClientPassword; - + /** * Base URL to MangoPay API - * @var string + * @var string */ /**Producion URL changes to {public $BaseUrl = 'https://api.mangopay.com';}**/ public $BaseUrl = 'https://api.sandbox.mangopay.com'; @@ -33,12 +33,12 @@ class Configuration { /** * Absolute path to file holding one or more certificates to verify the peer with. * If empty - don't verifying the peer's certificate. - * @var string + * @var string */ public $CertificatesFilePath = ''; /** - * [INTERNAL USAGE ONLY] + * [INTERNAL USAGE ONLY] * Switch debug mode: log all request and response data */ public $DebugMode = false; diff --git a/MangoPay/Libraries/DefaultStorageStrategy.php b/MangoPay/Libraries/DefaultStorageStrategy.php index 20b22fa1..df3d57ac 100644 --- a/MangoPay/Libraries/DefaultStorageStrategy.php +++ b/MangoPay/Libraries/DefaultStorageStrategy.php @@ -4,13 +4,14 @@ /** * Default storage strategy implementation. */ -class DefaultStorageStrategy implements IStorageStrategy { - +class DefaultStorageStrategy implements IStorageStrategy +{ private $_prefixContent = ''; private $_fileName = 'MangoPaySdkStorage.tmp.php'; private $_config; - function __construct($config) { + public function __construct($config) + { $this->_config = $config; } @@ -18,15 +19,17 @@ function __construct($config) { * Gets the current authorization token. * @return \MangoPay\Libraries\OAuthToken Currently stored token instance or null. */ - public function Get() { - + public function Get() + { $filename = $this->GetPathToFile(); - if (!file_exists($filename)) + if (!file_exists($filename)) { return null; + } $data = file_get_contents($filename); - if ($data === false) + if ($data === false) { return null; + } $serialized = str_replace($this->_prefixContent, '', $data); return unserialize($serialized); @@ -36,34 +39,38 @@ public function Get() { * Stores authorization token passed as an argument. * @param \MangoPay\Libraries\OAuthToken $token Token instance to be stored. */ - public function Store($token) { - - if (!is_writable($this->GetPathToTemporaryFolder())) + public function Store($token) + { + if (!is_writable($this->GetPathToTemporaryFolder())) { throw new \MangoPay\Libraries\Exception('Cannot create or write to file ' . $this->GetPathToTemporaryFolder()); + } $serialized = serialize($token); $result = file_put_contents($this->GetPathToFile(), $this->_prefixContent . $serialized, LOCK_EX); - if ($result === false) + if ($result === false) { throw new \MangoPay\Libraries\Exception('Cannot put token to file'); + } } /** - * Get path to storage file + * Get path to storage file * @return string */ - private function GetPathToFile() { + private function GetPathToFile() + { return $this->GetPathToTemporaryFolder() . DIRECTORY_SEPARATOR . $this->_fileName; } /** - * Get path to temporary folder + * Get path to temporary folder * @return string */ - private function GetPathToTemporaryFolder() { - - if (is_null($this->_config->TemporaryFolder)) + private function GetPathToTemporaryFolder() + { + if (is_null($this->_config->TemporaryFolder)) { throw new \MangoPay\Libraries\Exception('Path to temporary folder is not defined'); + } return $this->_config->TemporaryFolder; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/Dto.php b/MangoPay/Libraries/Dto.php index 11e495f0..ced1d258 100644 --- a/MangoPay/Libraries/Dto.php +++ b/MangoPay/Libraries/Dto.php @@ -5,26 +5,35 @@ /** * Abstract class for all DTOs (entities and their composites) */ -abstract class Dto { - +abstract class Dto +{ /** * Get array with mapping which property is object and what type of object. * To be overridden in child class if has any sub objects. * @return array */ - public function GetSubObjects() { return array(); } + public function GetSubObjects() + { + return array(); + } /** - * Get array with mapping which property depends on other property + * Get array with mapping which property depends on other property * To be overridden in child class if has any dependent objects. * @return array */ - public function GetDependsObjects() { return array(); } + public function GetDependsObjects() + { + return array(); + } /** * Get array with read only properties - not used in response * To be overridden in child class if has any read-only properties. * @return array */ - public function GetReadOnlyProperties() { return array(); } + public function GetReadOnlyProperties() + { + return array(); + } } diff --git a/MangoPay/Libraries/EntityBase.php b/MangoPay/Libraries/EntityBase.php index 7a5e518d..3a9cd527 100644 --- a/MangoPay/Libraries/EntityBase.php +++ b/MangoPay/Libraries/EntityBase.php @@ -5,8 +5,8 @@ /** * Abstract class with common properties */ -abstract class EntityBase extends Dto { - +abstract class EntityBase extends Dto +{ /** * @var Int Unique identifier * (At this moment type is Integer - in the feature will be GUID) @@ -27,7 +27,8 @@ abstract class EntityBase extends Dto { * Construct * @param type $id Entity identifier */ - function __construct($id = null) { + public function __construct($id = null) + { $this->Id = $id; } @@ -35,7 +36,8 @@ function __construct($id = null) { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { return array( 'Id', 'CreationDate' ); } } diff --git a/MangoPay/Libraries/Error.php b/MangoPay/Libraries/Error.php index 069ec15e..1ecd5487 100644 --- a/MangoPay/Libraries/Error.php +++ b/MangoPay/Libraries/Error.php @@ -5,8 +5,8 @@ /** * Class represents error object */ -class Error { - +class Error +{ /** * Error message * @var String @@ -20,7 +20,4 @@ class Error { * @access public */ public $Errors; - - - } diff --git a/MangoPay/Libraries/Exception.php b/MangoPay/Libraries/Exception.php index 94048219..cf8516ca 100644 --- a/MangoPay/Libraries/Exception.php +++ b/MangoPay/Libraries/Exception.php @@ -1,5 +1,6 @@ '; print $message . ': '; print_r($data); print '
-------------------------------'; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/OAuthToken.php b/MangoPay/Libraries/OAuthToken.php index d581eaa5..df85d21e 100644 --- a/MangoPay/Libraries/OAuthToken.php +++ b/MangoPay/Libraries/OAuthToken.php @@ -4,8 +4,8 @@ /** * OAuthToken */ -class OAuthToken extends Dto { - +class OAuthToken extends Dto +{ /** * Created time * @var int @@ -33,7 +33,8 @@ class OAuthToken extends Dto { /** * Constructor */ - function __construct() { + public function __construct() + { $this->create_time = time() - 5; } @@ -41,7 +42,8 @@ function __construct() { * Check that current tokens are expire and return true if yes * @return bool */ - public function IsExpired() { + public function IsExpired() + { return (time() >= ($this->create_time + $this->expires_in)); } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/RequestType.php b/MangoPay/Libraries/RequestType.php index 58cdbc5a..45cd6134 100644 --- a/MangoPay/Libraries/RequestType.php +++ b/MangoPay/Libraries/RequestType.php @@ -4,9 +4,10 @@ /** * Request type enum */ -class RequestType { +class RequestType +{ const GET = 'GET'; const POST = 'POST'; const PUT = 'PUT'; const DELETE = 'DELETE'; -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/ResponseException.php b/MangoPay/Libraries/ResponseException.php index d2574e83..0c491cbd 100644 --- a/MangoPay/Libraries/ResponseException.php +++ b/MangoPay/Libraries/ResponseException.php @@ -4,8 +4,8 @@ /** * Response exception class */ -class ResponseException extends Exception { - +class ResponseException extends Exception +{ /** * Array with response code and corresponding response message * @var array @@ -26,7 +26,7 @@ class ResponseException extends Exception { /** * Error details - * @var Error + * @var Error */ private $_errorInfo; @@ -41,8 +41,8 @@ class ResponseException extends Exception { * @param int $code Response code * @param Error $errorInfo Details with the error */ - function __construct($requestUrl, $code, $errorInfo = null) { - + public function __construct($requestUrl, $code, $errorInfo = null) + { $this->RequestUrl = $requestUrl; $this->_code = $code; @@ -64,7 +64,8 @@ function __construct($requestUrl, $code, $errorInfo = null) { * Get Error object returned by REST API * @return Error */ - public function GetErrorDetails(){ + public function GetErrorDetails() + { return $this->_errorInfo; } -} \ No newline at end of file +} diff --git a/MangoPay/Libraries/RestTool.php b/MangoPay/Libraries/RestTool.php index 7b003b16..91aa16cb 100644 --- a/MangoPay/Libraries/RestTool.php +++ b/MangoPay/Libraries/RestTool.php @@ -5,8 +5,8 @@ /** * Class to prepare HTTP request, call the request and decode the response */ -class RestTool { - +class RestTool +{ /** * Root/parent instance that holds the OAuthToken and Configuration instance * @var \MangoPay\MangoPayApi @@ -15,37 +15,37 @@ class RestTool { /** * Variable to flag that in request authentication data are required - * @var bool + * @var bool */ private $_authRequired; /** * Array with HTTP header to send with request - * @var array + * @var array */ private $_requestHttpHeaders; /** * cURL handle - * @var resource + * @var resource */ private $_curlHandle; /** * Request type for current request - * @var RequestType + * @var RequestType */ private $_requestType; /** * Array with data to pass in the request - * @var array + * @var array */ private $_requestData; /** * Code get from response - * @var int + * @var int */ private $_responseCode; @@ -56,7 +56,7 @@ class RestTool { /** * Pagination object - * @var MangoPay\Pagination + * @var MangoPay\Pagination */ private $_pagination; @@ -69,16 +69,18 @@ class RestTool { * @param bool $authRequired Variable to flag that in request the authentication data are required * @param \MangoPay\MangoPayApi Root/parent instance that holds the OAuthToken and Configuration instance */ - function __construct($authRequired = true, $root) { + public function __construct($authRequired = true, $root) + { $this->_authRequired = $authRequired; $this->_root = $root; $this->logger = $root->getLogger(); } - public function AddRequestHttpHeader($httpHeader) { - - if (is_null($this->_requestHttpHeaders)) + public function AddRequestHttpHeader($httpHeader) + { + if (is_null($this->_requestHttpHeaders)) { $this->_requestHttpHeaders = array(); + } array_push($this->_requestHttpHeaders, $httpHeader); } @@ -92,8 +94,9 @@ public function AddRequestHttpHeader($httpHeader) { * @param array Array with additional parameters to URL. Expected keys: "sort" and "filter" * @return object Response data */ - public function Request($urlMethod, $requestType, $requestData = null, $idempotencyKey = null, & $pagination = null, $additionalUrlParams = null) { - + public function Request($urlMethod, $requestType, $requestData = null, $idempotencyKey = null, & $pagination = null, $additionalUrlParams = null) + { + $this->_requestType = $requestType; $this->_requestData = $requestData; @@ -106,6 +109,7 @@ public function Request($urlMethod, $requestType, $requestData = null, $idempote $this->BuildRequest($urlMethod, $pagination, $additionalUrlParams, $idempotencyKey); $responseResult = $this->RunRequest(); + if(!is_null($pagination)) { $pagination = $this->_pagination; } @@ -118,12 +122,11 @@ public function Request($urlMethod, $requestType, $requestData = null, $idempote * @return object Response data * @throws Exception If cURL has error */ - private function RunRequest() { - + private function RunRequest() + { $result = curl_exec($this->_curlHandle); if ($result === false && curl_errno($this->_curlHandle) != 0) { $this->logger->error("cURL error: " . curl_error($this->_curlHandle)); - throw new Exception('cURL error: ' . curl_error($this->_curlHandle)); } @@ -156,8 +159,8 @@ private function RunRequest() { * @param String $urlMethod Type of method in REST API * @throws Exception If some parameters are not set */ - private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = null, $idempotencyKey = null) { - + private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = null, $idempotencyKey = null) + { $urlTool = new UrlTool($this->_root); $restUrl = $urlTool->GetRestUrl($urlMethod, $this->_authRequired, $pagination, $additionalUrlParams); @@ -170,17 +173,16 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu } $this->_curlHandle = curl_init($this->_requestUrl); - if ($this->_curlHandle === false){ + if ($this->_curlHandle === false) { $this->logger->error('Cannot initialize cURL session'); - throw new Exception('Cannot initialize cURL session'); } curl_setopt($this->_curlHandle, CURLOPT_RETURNTRANSFER, true); - if ($this->_root->Config->CertificatesFilePath == '') + if ($this->_root->Config->CertificatesFilePath == '') { curl_setopt($this->_curlHandle, CURLOPT_SSL_VERIFYPEER, false); - else { + } else { curl_setopt($this->_curlHandle, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($this->_curlHandle, CURLOPT_CAINFO, $this->_root->Config->CertificatesFilePath); } @@ -203,6 +205,7 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu } $this->logger->debug('RequestType : ' . $this->_requestType); + if ($this->_root->Config->DebugMode) { $logClass::Debug('RequestType', $this->_requestType); } @@ -212,13 +215,14 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu curl_setopt($this->_curlHandle, CURLOPT_HTTPHEADER, $httpHeaders); $this->logger->debug('HTTP Headers : ' . print_r($httpHeaders, true)); + if ($this->_root->Config->DebugMode) { $logClass::Debug('HTTP Headers', $httpHeaders); } if (!is_null($this->_requestData)) { - $this->logger->debug('RequestData object :' . print_r($this->_requestData, true)); + if ($this->_root->Config->DebugMode) { $logClass::Debug('RequestData object', $this->_requestData); } @@ -228,8 +232,8 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu // FIXME This can also fail hard and is not checked. $this->_requestData = json_encode($this->_requestData); - $this->logger->debug('RequestData JSON :' . print_r($this->_requestData, true)); + if ($this->_root->Config->DebugMode) { $logClass::Debug('RequestData JSON', $this->_requestData); } @@ -245,13 +249,15 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu * @param string $header Header from response * @return int Length of header */ - private function ReadResponseHeader($handle, $header) { - + private function ReadResponseHeader($handle, $header) + { $logClass = $this->_root->Config->LogClass; $this->logger->debug('Response headers :' . $header); - if ($this->_root->Config->DebugMode) + + if ($this->_root->Config->DebugMode) { $logClass::Debug('Response headers', $header); + } if (strpos($header, 'X-Number-Of-Pages:') !== false) { $this->_pagination->TotalPages = (int)trim(str_replace('X-Number-Of-Pages:', '', $header)); @@ -262,17 +268,16 @@ private function ReadResponseHeader($handle, $header) { } if (strpos($header, 'Link: ') !== false) { - $strLinks = trim(str_replace('Link:', '', $header)); $arrayLinks = explode(',', $strLinks); if ($arrayLinks !== false) { $this->_pagination->Links = array(); foreach ($arrayLinks as $link) { - $tmp = str_replace(array('<"', '">', ' rel="', '"'), '', $link); $oneLink = explode(';', $tmp); - if (is_array($oneLink) && isset($oneLink[0]) && isset($oneLink[1])) + if (is_array($oneLink) && isset($oneLink[0]) && isset($oneLink[1])) { $this->_pagination->Links[$oneLink[1]] = $oneLink[0]; + } } } } @@ -282,9 +287,10 @@ private function ReadResponseHeader($handle, $header) { /** * Get HTTP header to use in request - * @return array Array with HTTP headers + * @return array Array with HTTP headers */ - private function GetHttpHeaders(){ + private function GetHttpHeaders() + { // return if already created... if (!is_null($this->_requestHttpHeaders)) { return $this->_requestHttpHeaders; @@ -300,7 +306,7 @@ private function GetHttpHeaders(){ if ($this->_authRequired) { $authHlp = new AuthenticationHelper($this->_root); array_push($this->_requestHttpHeaders, $authHlp->GetHttpHeaderKey()); - } + } return $this->_requestHttpHeaders; } @@ -310,20 +316,17 @@ private function GetHttpHeaders(){ * @param object $response Response from REST API * @throws ResponseException If response code not OK */ - private function CheckResponseCode($response){ - + private function CheckResponseCode($response) + { if ($this->_responseCode != 200) { - if (isset($response) && is_object($response) && isset($response->Message)) { - $error = new Error(); $error->Message = $response->Message; - $error->Errors = property_exists($response, 'Errors') - ? $response->Errors + $error->Errors = property_exists($response, 'Errors') + ? $response->Errors : property_exists($response, 'errors') ? $response->errors : null; throw new ResponseException($this->_requestUrl, $this->_responseCode, $error); - - } else { + } else { throw new ResponseException($this->_requestUrl, $this->_responseCode); } } diff --git a/MangoPay/Libraries/UrlTool.php b/MangoPay/Libraries/UrlTool.php index 469e935b..b1f429ff 100644 --- a/MangoPay/Libraries/UrlTool.php +++ b/MangoPay/Libraries/UrlTool.php @@ -1,8 +1,8 @@ _root = $root; } - private function GetHost(){ - - if (is_null($this->_root->Config->BaseUrl) || strlen($this->_root->Config->BaseUrl) == 0) - throw new Exception ('Neither MangoPay_BaseUrl constant nor BaseUrl config setting is defined.'); + private function GetHost() + { + if (is_null($this->_root->Config->BaseUrl) || strlen($this->_root->Config->BaseUrl) == 0) { + throw new Exception('Neither MangoPay_BaseUrl constant nor BaseUrl config setting is defined.'); + } $baseUrl = $this->_root->Config->BaseUrl; - if (strpos($baseUrl, '/', strlen($baseUrl) - 1 )) - $baseUrl = substr ($baseUrl, 0, strlen($baseUrl) - 1); + if (strpos($baseUrl, '/', strlen($baseUrl) - 1)) { + $baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1); + } return $baseUrl; } - public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $additionalUrlParams = null) { - + public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $additionalUrlParams = null) + { if (!$addClientId) { $url = '/v2.01' . $urlKey; } else { @@ -44,7 +47,6 @@ public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $ad } if (!is_null($additionalUrlParams)) { - if (array_key_exists("sort", $additionalUrlParams)) { $url .= $paramsAdded ? '&' : '?'; $url .= http_build_query($additionalUrlParams["sort"]); @@ -61,7 +63,8 @@ public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $ad return $url; } - public function GetFullUrl($restUrl) { + public function GetFullUrl($restUrl) + { return $this->GetHost() . $restUrl; - } + } } diff --git a/MangoPay/MangoPayApi.php b/MangoPay/MangoPayApi.php index c319e3c9..7da0b51f 100644 --- a/MangoPay/MangoPayApi.php +++ b/MangoPay/MangoPayApi.php @@ -9,8 +9,8 @@ * Provides managers to connect, send and read data from MangoPay API * as well as holds configuration/authorization data. */ -class MangoPayApi { - +class MangoPayApi +{ ///////////////////////////////////////////////// // Config/authorization related props ///////////////////////////////////////////////// @@ -45,13 +45,13 @@ class MangoPayApi { /** * Clients methods - * @var Client + * @var Client */ public $Clients; /** * Users methods - * @var ApiUsers + * @var ApiUsers */ public $Users; @@ -69,55 +69,55 @@ class MangoPayApi { /** * Pay-in methods - * @var ApiPayIns + * @var ApiPayIns */ public $PayIns; /** * Pay-out methods - * @var ApiPayOuts + * @var ApiPayOuts */ public $PayOuts; /** * Refund methods - * @var ApiRefunds + * @var ApiRefunds */ public $Refunds; /** * Card registration methods - * @var ApiCardRegistrations + * @var ApiCardRegistrations */ - public $CardRegistrations; + public $CardRegistrations; /** * Pre-authorization methods - * @var ApiCardPreAuthorization + * @var ApiCardPreAuthorization */ public $CardPreAuthorizations; /** * Card methods - * @var ApiCards + * @var ApiCards */ public $Cards; /** * Events methods - * @var ApiEvents + * @var ApiEvents */ public $Events; /** * Hooks methods - * @var ApiHooks + * @var ApiHooks */ public $Hooks; /** * Kyc documents list - * @var ApiKycDocuments + * @var ApiKycDocuments */ public $KycDocuments; @@ -141,7 +141,8 @@ class MangoPayApi { /** * Constructor */ - function __construct() { + public function __construct() + { // default config setup $this->Config = new Libraries\Configuration(); @@ -186,4 +187,4 @@ public function getLogger() { return $this->logger; } -} \ No newline at end of file +} diff --git a/MangoPay/Money.php b/MangoPay/Money.php index 667c2f75..0b4956ba 100644 --- a/MangoPay/Money.php +++ b/MangoPay/Money.php @@ -5,8 +5,8 @@ /** * Class represents money value with currency */ -class Money extends Libraries\Dto { - +class Money extends Libraries\Dto +{ /** * Text with currency code with ISO 4217 standard * @var String diff --git a/MangoPay/Pagination.php b/MangoPay/Pagination.php index 8a74f5ab..9c50153b 100644 --- a/MangoPay/Pagination.php +++ b/MangoPay/Pagination.php @@ -5,8 +5,8 @@ /** * Class represents pagination information */ -class Pagination extends Libraries\Dto { - +class Pagination extends Libraries\Dto +{ /** * Page number * @var Int @@ -32,7 +32,7 @@ class Pagination extends Libraries\Dto { public $TotalItems; /** - * Array with links to navigation. + * Array with links to navigation. * All values optional. Format: * array( * first => http url @@ -40,7 +40,7 @@ class Pagination extends Libraries\Dto { * next => http url * last => http url * ) - * @var array + * @var array */ public $Links = array(); @@ -49,8 +49,9 @@ class Pagination extends Libraries\Dto { * @param int $page Number of page * @param int $itemsPerPage Number of items on one page */ - function __construct($page = 1, $itemsPerPage = 10) { + public function __construct($page = 1, $itemsPerPage = 10) + { $this->Page = $page; $this->ItemsPerPage = $itemsPerPage; } -} \ No newline at end of file +} diff --git a/MangoPay/PayIn.php b/MangoPay/PayIn.php index 54607414..6c81cc84 100644 --- a/MangoPay/PayIn.php +++ b/MangoPay/PayIn.php @@ -4,8 +4,8 @@ /** * Pay-in entity */ -class PayIn extends Transaction { - +class PayIn extends Transaction +{ /** * Credited wallet Id * @var int @@ -14,33 +14,34 @@ class PayIn extends Transaction { /** * PaymentType {CARD, BANK_WIRE, AUTOMATIC_DEBIT, DIRECT_DEBIT } - * @var string + * @var string */ public $PaymentType; /** * One of PayInPaymentDetails implementations, depending on $PaymentType - * @var object + * @var object */ public $PaymentDetails; /** * ExecutionType { WEB, TOKEN, DIRECT, PREAUTHORIZED, RECURRING_ORDER_EXECUTION } - * @var string + * @var string */ public $ExecutionType; /** * One of PayInExecutionDetails implementations, depending on $ExecutionType - * @var object + * @var object */ public $ExecutionDetails; /** - * Get array with mapping which property depends on other property + * Get array with mapping which property depends on other property * @return array */ - public function GetDependsObjects() { + public function GetDependsObjects() + { return array( 'PaymentType' => array( '_property_name' => 'PaymentDetails', @@ -63,10 +64,11 @@ public function GetDependsObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'PaymentType' ); - array_push( $properties, 'ExecutionType' ); + array_push($properties, 'PaymentType'); + array_push($properties, 'ExecutionType'); return $properties; } diff --git a/MangoPay/PayInExecutionDetails.php b/MangoPay/PayInExecutionDetails.php index 0e0c8893..4e8d6d6a 100644 --- a/MangoPay/PayInExecutionDetails.php +++ b/MangoPay/PayInExecutionDetails.php @@ -4,4 +4,6 @@ /** * Marker interface for classes with details of execution option in PayIn entity */ -interface PayInExecutionDetails { } +interface PayInExecutionDetails +{ +} diff --git a/MangoPay/PayInExecutionDetailsDirect.php b/MangoPay/PayInExecutionDetailsDirect.php index 1b5d35b4..fe26aba4 100644 --- a/MangoPay/PayInExecutionDetailsDirect.php +++ b/MangoPay/PayInExecutionDetailsDirect.php @@ -4,8 +4,8 @@ /** * Class represents Web type for execution option in PayIn entity */ -class PayInExecutionDetailsDirect extends Libraries\Dto implements PayInExecutionDetails { - +class PayInExecutionDetailsDirect extends Libraries\Dto implements PayInExecutionDetails +{ /** * SecureMode { DEFAULT, FORCE } * @var string @@ -14,19 +14,19 @@ class PayInExecutionDetailsDirect extends Libraries\Dto implements PayInExecutio /** * SecureModeReturnURL - * @var string + * @var string */ public $SecureModeReturnURL; /** * SecureModeRedirectURL - * @var string + * @var string */ public $SecureModeRedirectURL; - - /** + + /** * SecureModeNeeded - * @var string + * @var string */ public $SecureModeNeeded; } diff --git a/MangoPay/PayInExecutionDetailsWeb.php b/MangoPay/PayInExecutionDetailsWeb.php index fc9ac831..c3f98406 100644 --- a/MangoPay/PayInExecutionDetailsWeb.php +++ b/MangoPay/PayInExecutionDetailsWeb.php @@ -4,8 +4,8 @@ /** * Class represents Web type for execution option in PayIn entity */ -class PayInExecutionDetailsWeb extends Libraries\Dto implements PayInExecutionDetails { - +class PayInExecutionDetailsWeb extends Libraries\Dto implements PayInExecutionDetails +{ /** * URL format expected * @var string @@ -26,13 +26,13 @@ class PayInExecutionDetailsWeb extends Libraries\Dto implements PayInExecutionDe /** * The URL where you host the iFramed template. - * For CB, Visa, MasterCard you need to specify PAYLINE: before your URL - * with the iFramed template + * For CB, Visa, MasterCard you need to specify PAYLINE: before your URL + * with the iFramed template * ex: PAYLINE: https://www.maysite.com/payline_template/ * Used for: * - direct debit web type pay-in. - * - * @var PayInTemplateURLOptions + * + * @var PayInTemplateURLOptions */ public $TemplateURLOptions; @@ -51,20 +51,22 @@ class PayInExecutionDetailsWeb extends Libraries\Dto implements PayInExecutionDe * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'RedirectURL' ); + array_push($properties, 'RedirectURL'); return $properties; } /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ - public function GetSubObjects() { + public function GetSubObjects() + { return array( 'TemplateURLOptions' => '\MangoPay\PayInTemplateURLOptions' ); } -} \ No newline at end of file +} diff --git a/MangoPay/PayInPaymentDetails.php b/MangoPay/PayInPaymentDetails.php index 4eb46de7..d70a9cc6 100644 --- a/MangoPay/PayInPaymentDetails.php +++ b/MangoPay/PayInPaymentDetails.php @@ -4,4 +4,6 @@ /** * Marker interface for classes with details of means of payment in PayIn entity */ -interface PayInPaymentDetails { } +interface PayInPaymentDetails +{ +} diff --git a/MangoPay/PayInPaymentDetailsBankWire.php b/MangoPay/PayInPaymentDetailsBankWire.php index 0707587f..94bd05a9 100644 --- a/MangoPay/PayInPaymentDetailsBankWire.php +++ b/MangoPay/PayInPaymentDetailsBankWire.php @@ -4,8 +4,8 @@ /** * Class represents BankWire type for mean of payment in PayIn entity */ -class PayInPaymentDetailsBankWire extends Libraries\Dto implements PayInPaymentDetails { - +class PayInPaymentDetailsBankWire extends Libraries\Dto implements PayInPaymentDetails +{ /** * Declared debited funds * @var \MangoPay\Money @@ -26,15 +26,16 @@ class PayInPaymentDetailsBankWire extends Libraries\Dto implements PayInPaymentD /** * Wire reference - * @var string + * @var string */ public $WireReference; /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ - public function GetSubObjects() { + public function GetSubObjects() + { return array( 'DeclaredDebitedFunds' => '\MangoPay\Money' , 'DeclaredFees' => '\MangoPay\Money' , diff --git a/MangoPay/PayInPaymentDetailsCard.php b/MangoPay/PayInPaymentDetailsCard.php index 062d8ae1..37a99140 100644 --- a/MangoPay/PayInPaymentDetailsCard.php +++ b/MangoPay/PayInPaymentDetailsCard.php @@ -4,8 +4,8 @@ /** * Class represents Card type for mean of payment in PayIn entity */ -class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetails { - +class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetails +{ /** * CardType { CB_VISA_MASTERCARD, AMEX } * @var string @@ -14,7 +14,7 @@ class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetai /** * CardId - * @var string + * @var string */ public $CardId; } diff --git a/MangoPay/PayInPaymentDetailsDirectDebit.php b/MangoPay/PayInPaymentDetailsDirectDebit.php index c0f814f6..9cd4c449 100644 --- a/MangoPay/PayInPaymentDetailsDirectDebit.php +++ b/MangoPay/PayInPaymentDetailsDirectDebit.php @@ -4,8 +4,8 @@ /** * Class represents direct debit type for mean of payment in PayIn entity */ -class PayInPaymentDetailsDirectDebit extends Libraries\Dto implements PayInPaymentDetails { - +class PayInPaymentDetailsDirectDebit extends Libraries\Dto implements PayInPaymentDetails +{ /** * Direct debit type {SOFORT, ELV, GIROPAY} * @var string diff --git a/MangoPay/PayInPaymentDetailsPreAuthorized.php b/MangoPay/PayInPaymentDetailsPreAuthorized.php index 4de44dfe..0bd23b4f 100644 --- a/MangoPay/PayInPaymentDetailsPreAuthorized.php +++ b/MangoPay/PayInPaymentDetailsPreAuthorized.php @@ -4,11 +4,11 @@ /** * Class represents Web type for execution option in PayIn entity */ -class PayInPaymentDetailsPreAuthorized extends Libraries\Dto implements PayInPaymentDetails { - +class PayInPaymentDetailsPreAuthorized extends Libraries\Dto implements PayInPaymentDetails +{ /** * The ID of the Preauthorization object * @var string */ public $PreauthorizationId; -} \ No newline at end of file +} diff --git a/MangoPay/PayInTemplateURLOptions.php b/MangoPay/PayInTemplateURLOptions.php index 82cee316..ce227f73 100644 --- a/MangoPay/PayInTemplateURLOptions.php +++ b/MangoPay/PayInTemplateURLOptions.php @@ -4,12 +4,12 @@ /** * Class represents template URL options */ -class PayInTemplateURLOptions extends Libraries\Dto { - +class PayInTemplateURLOptions extends Libraries\Dto +{ /** * PAYLINE options - * - * @var string + * + * @var string */ public $PAYLINE; -} \ No newline at end of file +} diff --git a/MangoPay/PayOut.php b/MangoPay/PayOut.php index 084b9ac4..1ca77cd2 100644 --- a/MangoPay/PayOut.php +++ b/MangoPay/PayOut.php @@ -4,8 +4,8 @@ /** * PayOut entity */ -class PayOut extends Transaction { - +class PayOut extends Transaction +{ /** * Debited wallet Id * @var int @@ -14,22 +14,23 @@ class PayOut extends Transaction { /** * PaymentType (BANK_WIRE, MERCHANT_EXPENSE, AMAZON_GIFTCARD) - * @var string + * @var string */ public $PaymentType; /** * One of PayOutPaymentDetails implementations, depending on $PaymentType - * @var object + * @var object */ public $MeanOfPaymentDetails; /** - * Get array with mapping which property depends on other property + * Get array with mapping which property depends on other property * @return array */ - public function GetDependsObjects() { + public function GetDependsObjects() + { return array( 'PaymentType' => array( '_property_name' => 'MeanOfPaymentDetails', @@ -43,10 +44,11 @@ public function GetDependsObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'PaymentType' ); + array_push($properties, 'PaymentType'); return $properties; } -} \ No newline at end of file +} diff --git a/MangoPay/PayOutPaymentDetails.php b/MangoPay/PayOutPaymentDetails.php index ed7c1511..4f14f7d5 100644 --- a/MangoPay/PayOutPaymentDetails.php +++ b/MangoPay/PayOutPaymentDetails.php @@ -4,4 +4,6 @@ /** * Marker interface for classes with details of means of payment in PayOut entity */ -interface PayOutPaymentDetails { } +interface PayOutPaymentDetails +{ +} diff --git a/MangoPay/PayOutPaymentDetailsBankWire.php b/MangoPay/PayOutPaymentDetailsBankWire.php index 0b902825..34acf2b5 100644 --- a/MangoPay/PayOutPaymentDetailsBankWire.php +++ b/MangoPay/PayOutPaymentDetailsBankWire.php @@ -4,8 +4,8 @@ /** * Class represents BankWire type for mean of payment in PayOut entity */ -class PayOutPaymentDetailsBankWire extends Libraries\Dto implements PayOutPaymentDetails { - +class PayOutPaymentDetailsBankWire extends Libraries\Dto implements PayOutPaymentDetails +{ /** * Bank account Id * @var string @@ -13,7 +13,7 @@ class PayOutPaymentDetailsBankWire extends Libraries\Dto implements PayOutPaymen public $BankAccountId; /** - * A custom reference you wish to appear on the user’s bank statement + * A custom reference you wish to appear on the user’s bank statement * @var string */ public $BankWireRef; diff --git a/MangoPay/PersonType.php b/MangoPay/PersonType.php index f1014fb6..76be65bd 100644 --- a/MangoPay/PersonType.php +++ b/MangoPay/PersonType.php @@ -4,7 +4,8 @@ /** * Person type for users */ -class PersonType { +class PersonType +{ const Natural = 'NATURAL'; const Legal = 'LEGAL'; -} \ No newline at end of file +} diff --git a/MangoPay/Refund.php b/MangoPay/Refund.php index 5c2d5d82..db7aff7d 100644 --- a/MangoPay/Refund.php +++ b/MangoPay/Refund.php @@ -4,8 +4,8 @@ /** * Refund entity */ -class Refund extends Transaction { - +class Refund extends Transaction +{ /** * Initial transaction Id * @var string @@ -37,15 +37,15 @@ class Refund extends Transaction { public $RefundReason; /** - * Get array with mapping which property is object and what type of object - * + * Get array with mapping which property is object and what type of object + * * @return array */ - public function GetSubObjects() { - + public function GetSubObjects() + { $subObjects = parent::GetSubObjects(); $subObjects['RefundReason'] = '\MangoPay\RefundReasonDetails'; return $subObjects; - } + } } diff --git a/MangoPay/RefundReasonDetails.php b/MangoPay/RefundReasonDetails.php index 911225e8..ee46a39d 100644 --- a/MangoPay/RefundReasonDetails.php +++ b/MangoPay/RefundReasonDetails.php @@ -4,8 +4,8 @@ /** * Class represents RefundReason details in Refund entity */ -class RefundReasonDetails extends Libraries\Dto { - +class RefundReasonDetails extends Libraries\Dto +{ /** * Message about the reason for refund * @var string @@ -17,4 +17,4 @@ class RefundReasonDetails extends Libraries\Dto { * @var string */ public $RefundReasonType; -} \ No newline at end of file +} diff --git a/MangoPay/SortDirection.php b/MangoPay/SortDirection.php index afc0e07b..4cb1a741 100644 --- a/MangoPay/SortDirection.php +++ b/MangoPay/SortDirection.php @@ -1,7 +1,8 @@ _sortFields[$filedName] = $sortDirection; } - public function AddFiled($filedName, $sortDirection) {//for backward comptability from before typo fix + public function AddFiled($filedName, $sortDirection) + { + //for backward comptability from before typo fix $this->AddField($filedName, $sortDirection); } /** * Get sort parametrs to URL - * @return array + * @return array */ - public function GetSortParameter() { + public function GetSortParameter() + { return array(self::SortUrlParameterName => $this->_getFields()); } - private function _getFields() { + private function _getFields() + { $sortValues = ""; foreach ($this->_sortFields as $key => $value) { - if (!empty($sortValues)){ + if (!empty($sortValues)) { $sortValues .= self::SortFieldSeparator; } @@ -53,4 +58,4 @@ private function _getFields() { return $sortValues; } -} \ No newline at end of file +} diff --git a/MangoPay/TemporaryImmediatePayIn.php b/MangoPay/TemporaryImmediatePayIn.php index 77582994..cc987379 100644 --- a/MangoPay/TemporaryImmediatePayIn.php +++ b/MangoPay/TemporaryImmediatePayIn.php @@ -5,11 +5,11 @@ * WARNING!! * It's temporary entity and it will be removed in the future. * Please, contact with support before using these features or if you have any questions. - * + * * Temporary immediate pay-in entity. */ -class TemporaryImmediatePayIn extends Transaction { - +class TemporaryImmediatePayIn extends Transaction +{ /** * Payment card Id * @var string @@ -21,4 +21,4 @@ class TemporaryImmediatePayIn extends Transaction { * @var string */ public $CreditedWalletId; -} \ No newline at end of file +} diff --git a/MangoPay/TemporaryPaymentCard.php b/MangoPay/TemporaryPaymentCard.php index ae6f9500..331f6b58 100644 --- a/MangoPay/TemporaryPaymentCard.php +++ b/MangoPay/TemporaryPaymentCard.php @@ -5,11 +5,11 @@ * WARNING!! * It's temporary entity and it will be removed in the future. * Please, contact with support before using these features or if you have any questions. - * + * * Temporary Payment Card entity. */ -class TemporaryPaymentCard extends Libraries\EntityBase { - +class TemporaryPaymentCard extends Libraries\EntityBase +{ /** * User Id * @var string @@ -18,31 +18,31 @@ class TemporaryPaymentCard extends Libraries\EntityBase { /** * Culture - * @var string + * @var string */ public $Culture; /** * Return URL - * @var string + * @var string */ public $ReturnURL; /** * Template URL - * @var string + * @var string */ public $TemplateURL; /** * Redirect URL - * @var string + * @var string */ public $RedirectURL; /** * Alias - * @var string + * @var string */ public $Alias; -} \ No newline at end of file +} diff --git a/MangoPay/Transaction.php b/MangoPay/Transaction.php index c8987041..20a568ad 100644 --- a/MangoPay/Transaction.php +++ b/MangoPay/Transaction.php @@ -5,8 +5,8 @@ * Transaction entity. * Base class for: PayIn, PayOut, Transfer. */ -class Transaction extends Libraries\EntityBase { - +class Transaction extends Libraries\EntityBase +{ /** * Author Id * @var int @@ -15,7 +15,7 @@ class Transaction extends Libraries\EntityBase { /** * Credited user Id - * @var int + * @var int */ public $CreditedUserId; @@ -39,7 +39,7 @@ class Transaction extends Libraries\EntityBase { /** * TransactionStatus {CREATED, SUCCEEDED, FAILED} - * @var string + * @var string */ public $Status; @@ -51,7 +51,7 @@ class Transaction extends Libraries\EntityBase { /** * The PreAuthorization result Message explaining the result code - * @var string + * @var string */ public $ResultMessage; @@ -89,7 +89,8 @@ class Transaction extends Libraries\EntityBase { * Get array with mapping which property is object and what type of object * @return array */ - public function GetSubObjects() { + public function GetSubObjects() + { return array( 'DebitedFunds' => '\MangoPay\Money' , 'CreditedFunds' => '\MangoPay\Money' , @@ -101,11 +102,12 @@ public function GetSubObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'Status' ); - array_push( $properties, 'ResultCode' ); - array_push( $properties, 'ExecutionDate' ); + array_push($properties, 'Status'); + array_push($properties, 'ResultCode'); + array_push($properties, 'ExecutionDate'); return $properties; } diff --git a/MangoPay/Transfer.php b/MangoPay/Transfer.php index 1c285607..d6316f3b 100644 --- a/MangoPay/Transfer.php +++ b/MangoPay/Transfer.php @@ -4,8 +4,8 @@ /** * Transfer entity */ -class Transfer extends Transaction { - +class Transfer extends Transaction +{ /** * Debited wallet Id * @var int @@ -14,7 +14,7 @@ class Transfer extends Transaction { /** * Credited wallet Id - * @var int + * @var int */ public $CreditedWalletId; -} \ No newline at end of file +} diff --git a/MangoPay/User.php b/MangoPay/User.php index 06151e3a..ad61b5c8 100644 --- a/MangoPay/User.php +++ b/MangoPay/User.php @@ -5,8 +5,8 @@ /** * User entity */ -abstract class User extends Libraries\EntityBase { - +abstract class User extends Libraries\EntityBase +{ /** * Type of user * @var String @@ -15,13 +15,13 @@ abstract class User extends Libraries\EntityBase { /** * Email address - * @var String + * @var String */ public $Email; /** * KYC Level (LIGHT or REGULAR) - * @var String + * @var String */ public $KYCLevel; @@ -29,7 +29,8 @@ abstract class User extends Libraries\EntityBase { * Construct * @param string $personType String with type of person */ - protected function SetPersonType($personType) { + protected function SetPersonType($personType) + { $this->PersonType = $personType; } @@ -37,10 +38,11 @@ protected function SetPersonType($personType) { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'PersonType' ); + array_push($properties, 'PersonType'); return $properties; } -} \ No newline at end of file +} diff --git a/MangoPay/UserLegal.php b/MangoPay/UserLegal.php index 90a0529f..089cdef5 100644 --- a/MangoPay/UserLegal.php +++ b/MangoPay/UserLegal.php @@ -4,8 +4,8 @@ /** * UserLegal entity */ -class UserLegal extends User { - +class UserLegal extends User +{ /** * Name of user * @var String @@ -14,7 +14,7 @@ class UserLegal extends User { /** * Type for legal user. Possible: ‘BUSINESS’, ’ORGANIZATION’ - * @var String + * @var String */ public $LegalPersonType; @@ -25,14 +25,14 @@ class UserLegal extends User { public $HeadquartersAddress; /** - * - * @var String + * + * @var String */ public $LegalRepresentativeFirstName; /** - * - * @var String + * + * @var String */ public $LegalRepresentativeLastName; @@ -43,57 +43,58 @@ class UserLegal extends User { public $LegalRepresentativeAddress; /** - * - * @var String + * + * @var String */ public $LegalRepresentativeEmail; /** - * - * @var Unix timestamp + * + * @var Unix timestamp */ public $LegalRepresentativeBirthday; /** - * - * @var String + * + * @var String */ public $LegalRepresentativeNationality; /** - * - * @var String + * + * @var String */ public $LegalRepresentativeCountryOfResidence; - + /** - * - * @var String + * + * @var String */ public $ProofOfIdentity; - + /** - * - * @var String + * + * @var String */ public $Statute; /** - * - * @var String + * + * @var String */ public $ProofOfRegistration; /** - * - * @var String + * + * @var String */ public $ShareholderDeclaration; /** * Construct */ - function __construct($id = null) { + public function __construct($id = null) + { parent::__construct($id); $this->SetPersonType(PersonType::Legal); } @@ -115,12 +116,13 @@ public function GetSubObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'Statute' ); - array_push( $properties, 'ProofOfRegistration' ); - array_push( $properties, 'ShareholderDeclaration' ); + array_push($properties, 'Statute'); + array_push($properties, 'ProofOfRegistration'); + array_push($properties, 'ShareholderDeclaration'); return $properties; } -} \ No newline at end of file +} diff --git a/MangoPay/UserNatural.php b/MangoPay/UserNatural.php index 5e355f35..ccf52fad 100644 --- a/MangoPay/UserNatural.php +++ b/MangoPay/UserNatural.php @@ -4,8 +4,8 @@ /** * UserNatural entity */ -class UserNatural extends User { - +class UserNatural extends User +{ /** * First name for user * @var String @@ -14,7 +14,7 @@ class UserNatural extends User { /** * Last name for user - * @var String + * @var String */ public $LastName; @@ -26,50 +26,51 @@ class UserNatural extends User { /** * Date of birth - * @var Unix timestamp + * @var Unix timestamp */ public $Birthday; /** * User's country - * @var String + * @var String */ public $Nationality; /** * Country of residence - * @var String + * @var String */ public $CountryOfResidence; /** * User's occupation - * @var String + * @var String */ public $Occupation; /** - * - * @var Int + * + * @var Int */ public $IncomeRange; /** - * - * @var String + * + * @var String */ public $ProofOfIdentity; /** - * - * @var String + * + * @var String */ public $ProofOfAddress; /** * Construct */ - function __construct($id = null) { + public function __construct($id = null) + { parent::__construct($id); $this->SetPersonType(PersonType::Natural); } @@ -90,11 +91,12 @@ public function GetSubObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'ProofOfIdentity' ); - array_push( $properties, 'ProofOfAddress' ); + array_push($properties, 'ProofOfIdentity'); + array_push($properties, 'ProofOfAddress'); return $properties; } -} \ No newline at end of file +} diff --git a/MangoPay/Wallet.php b/MangoPay/Wallet.php index df99e5a5..8a1a1b78 100644 --- a/MangoPay/Wallet.php +++ b/MangoPay/Wallet.php @@ -4,8 +4,8 @@ /** * Wallet entity */ -class Wallet extends Libraries\EntityBase { - +class Wallet extends Libraries\EntityBase +{ /** * Array with owners identities * @var array @@ -14,13 +14,13 @@ class Wallet extends Libraries\EntityBase { /** * Wallet description - * @var string + * @var string */ public $Description; /** * Money in wallet - * @var Money + * @var Money */ public $Balance; @@ -31,10 +31,11 @@ class Wallet extends Libraries\EntityBase { public $Currency; /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ - public function GetSubObjects() { + public function GetSubObjects() + { return array( 'Balance' => '\MangoPay\Money' ); } @@ -42,9 +43,10 @@ public function GetSubObjects() { * Get array with read-only properties * @return array */ - public function GetReadOnlyProperties() { + public function GetReadOnlyProperties() + { $properties = parent::GetReadOnlyProperties(); - array_push( $properties, 'Balance' ); + array_push($properties, 'Balance'); return $properties; }