Skip to content

Commit

Permalink
Merge branch 'MockingMagician-feat/namespace-compliance'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoloJr committed May 11, 2021
2 parents d4e47e8 + 0b1d063 commit 5b5995c
Show file tree
Hide file tree
Showing 201 changed files with 1,281 additions and 1,112 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ demos/paymentDirect/MangoPaySdkStorage.tmp.php
/vendor/
composer.lock

.idea

.phpunit.result.cache
.*
!.php_cs
!.gitignore
16 changes: 16 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/MangoPay')
->in(__DIR__.'/tests')
;

$config = new PhpCsFixer\Config();

return $config->setRules([
'@PSR12' => true,
'fully_qualified_strict_types' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
;
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " tag to modify the version"

.PHONY: tag
tag:
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=2.5.1"))
@echo Tagging $(TAG)
sed -i "s/const VERSION = '.*';/const VERSION = '$(TAG)';/" MangoPay/Libraries/RestTool.php
php -l MangoPay/Libraries/RestTool.php

.PHONY: docker-test-php-56
docker-test-php-56: ## Test on PHP 5.6
docker build -t php-test-env:5.6 php_env/PHP_5.6
docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \
-w /usr/src/mangopay2-php-sdk \
--user $(shell id -u):$(shell id -g) \
php-test-env:5.6 \
/bin/bash -c "composer update -no --no-progress --no-suggest && vendor/bin/phpunit tests"

.PHONY: docker-test-php-70
docker-test-php-70: ## Test on PHP 7.0
docker build -t php-test-env:7.0 php_env/PHP_7.0
docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \
-w /usr/src/mangopay2-php-sdk \
--user $(shell id -u):$(shell id -g) \
php-test-env:7.0 \
/bin/bash -c "composer update -no --no-progress --no-suggest && vendor/bin/phpunit tests"

.PHONY: docker-test-php-80
docker-test-php-80: ## Test on PHP 8.0
docker build -t php-test-env:8.0 php_env/PHP_8.0
docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \
-w /usr/src/mangopay2-php-sdk \
--user $(shell id -u):$(shell id -g) \
php-test-env:8.0 \
/bin/bash -c "composer update -no --no-progress --no-suggest --ignore-platform-reqs && vendor/bin/phpunit tests"
4 changes: 2 additions & 2 deletions MangoPay/AVSResult.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace MangoPay;

/**
* Address Verification System result
*/
class AVSResult
{

const FULL_MATCH = "FULL_MATCH";

const ADDRESS_MATCH_ONLY = "ADDRESS_MATCH_ONLY";
Expand All @@ -16,4 +16,4 @@ class AVSResult
const NO_MATCH = "NO_MATCH";

const NO_CHECK = "NO_CHECK";
}
}
19 changes: 10 additions & 9 deletions MangoPay/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Class represents an address.
*/
class Address extends Libraries\Dto
{
{
/**
* Address line 1.
* @var string
Expand Down Expand Up @@ -42,18 +42,19 @@ class Address extends Libraries\Dto
* @var string
*/
public $Country;

public function CanBeNull()
{
return $this->IsEmpty($this->AddressLine1)
&& $this->IsEmpty($this->AddressLine2)
&& $this->IsEmpty($this->City)
&& $this->IsEmpty($this->Region)
&& $this->IsEmpty($this->PostalCode)
return $this->IsEmpty($this->AddressLine1)
&& $this->IsEmpty($this->AddressLine2)
&& $this->IsEmpty($this->City)
&& $this->IsEmpty($this->Region)
&& $this->IsEmpty($this->PostalCode)
&& $this->IsEmpty($this->Country);
}

private function IsEmpty($value){

private function IsEmpty($value)
{
return is_null($value) || empty($value);
}
}
3 changes: 2 additions & 1 deletion MangoPay/ApiBankAccounts.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php

namespace MangoPay;

/**
* Class to manage MangoPay API for bank accounts
*/
class ApiBankAccounts extends Libraries\ApiBase
{

/**
* Retrieves a list of Transactions pertaining to a certain Bank Account
* @param string $bankAccountId Bank Account identifier
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Filtering object
* @param \MangoPay\Sorting $sorting Sorting object
* @throws \MangoPay\Libraries\Exception
*/
public function GetTransactions($bankAccountId, & $pagination = null, $filter = null, $sorting = null)
{
Expand Down
4 changes: 2 additions & 2 deletions MangoPay/ApiBankingAliases.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand Down Expand Up @@ -57,7 +58,7 @@ public function Update($bankingAlias)
public function GetAll($walletId, & $pagination = null, $sorting = null)
{
$bankingAliases = $this->GetList('banking_aliases_all', $pagination, null, $walletId, null, $sorting);
return array_map(array($this, "GetBankingAliasResponse"), $bankingAliases);
return array_map([$this, "GetBankingAliasResponse"], $bankingAliases);
}

/**
Expand All @@ -79,5 +80,4 @@ private function GetBankingAliasResponse($response)
throw new Libraries\Exception('Unexpected response. Missing BankingAlias Type property');
}
}

}
5 changes: 3 additions & 2 deletions MangoPay/ApiCardPreAuthorizations.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand All @@ -15,7 +16,7 @@ public function Create($cardPreAuthorization, $idempotencyKey = null)
{
return $this->CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization', null, null, $idempotencyKey);
}

/**
* Get pre-authorization object
* @param string $cardPreAuthorizationId PreAuthorization identifier
Expand All @@ -25,7 +26,7 @@ public function Get($cardPreAuthorizationId)
{
return $this->GetObject('preauthorization_get', '\MangoPay\CardPreAuthorization', $cardPreAuthorizationId);
}

/**
* Update pre-authorization object
* @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to save
Expand Down
5 changes: 3 additions & 2 deletions MangoPay/ApiCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function GetTransactions($cardId, & $pagination = null, $filter = null, $
* @return \MangoPay\Card
* @throws Libraries\Exception
*/
public function ValidateCard($cardId){
public function ValidateCard($cardId)
{
return $this->GetObject('card_validate', '\MangoPay\Card', $cardId);
}
}
}
22 changes: 13 additions & 9 deletions MangoPay/ApiClients.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public function GetWallets($fundsType = null, $sorting = null)

if (is_null($fundsType)) {
return $this->GetList('client_wallets', $pagination, '\MangoPay\Wallet', null, null, $sorting);
} else if ($fundsType == FundsType::FEES) {
} elseif ($fundsType == FundsType::FEES) {
return $this->GetList('client_wallets_fees', $pagination, '\MangoPay\Wallet', null, null, $sorting);
} else if ($fundsType == FundsType::CREDIT) {
} elseif ($fundsType == FundsType::CREDIT) {
return $this->GetList('client_wallets_credit', $pagination, '\MangoPay\Wallet', null, null, $sorting);
}

Expand All @@ -118,18 +118,20 @@ public function GetWallet($fundsType, $currencyIso)
{
if (is_null($fundsType)) {
throw new \MangoPay\Libraries\Exception(
'First parameter in function GetWallet in class ApiClients is required.');
'First parameter in function GetWallet in class ApiClients is required.'
);
}

if (is_null($currencyIso)) {
throw new \MangoPay\Libraries\Exception(
'Second parameter in function GetWallet in class ApiClients is required.');
'Second parameter in function GetWallet in class ApiClients is required.'
);
}

$methodKey = null;
if ($fundsType == FundsType::FEES) {
$methodKey = 'client_wallets_fees_currency';
} else if ($fundsType == FundsType::CREDIT) {
} elseif ($fundsType == FundsType::CREDIT) {
$methodKey = 'client_wallets_credit_currency';
} else {
throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets');
Expand All @@ -152,18 +154,20 @@ public function GetWalletTransactions($fundsType = null, $currencyIso = null, &
{
if (is_null($fundsType)) {
$methodKey = 'client_wallets_transactions';
} else if ($fundsType == FundsType::FEES) {
} elseif ($fundsType == FundsType::FEES) {
$methodKey = 'client_wallets_transactions_fees_currency';
} else if ($fundsType == FundsType::CREDIT) {
} elseif ($fundsType == FundsType::CREDIT) {
$methodKey = 'client_wallets_transactions_credit_currency';
} else {
throw new \MangoPay\Libraries\Exception(
'\MangoPay\FundsType object has wrong value.');
'\MangoPay\FundsType object has wrong value.'
);
}

if (!is_null($fundsType) && is_null($currencyIso)) {
throw new \MangoPay\Libraries\Exception(
'If FundsType is defined the second parameter (currency) is required.');
'If FundsType is defined the second parameter (currency) is required.'
);
}

return $this->GetList($methodKey, $pagination, '\MangoPay\Transaction', $currencyIso, $filter, null);
Expand Down
1 change: 0 additions & 1 deletion MangoPay/ApiDisputes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
class ApiDisputes extends Libraries\ApiBase
{

/**
* Gets dispute
* @param string $disputeId Dispute identifier
Expand Down
1 change: 1 addition & 0 deletions MangoPay/ApiEvents.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand Down
3 changes: 2 additions & 1 deletion MangoPay/ApiReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public function Create($reportRequest, $idempotencyKey = null)
{
$type = $reportRequest->ReportType;

if (is_null($type) || strlen($type) == 0)
if (is_null($type) || strlen($type) == 0) {
throw new Libraries\Exception('Report type property is required when create a report request.');
}

switch ($type) {
case ReportType::Transactions:
Expand Down
2 changes: 1 addition & 1 deletion MangoPay/ApiRepudiations.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public function GetRefunds($repudiationId, & $pagination = null, $filter = null,
{
return $this->GetList('refunds_get_for_repudiation', $pagination, '\MangoPay\Repudiation', $repudiationId, $filter, $sorting);
}
}
}
3 changes: 2 additions & 1 deletion MangoPay/ApiResponses.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public function Get($idempotencyKey)
{
$response = $this->GetObject('responses_get', 'MangoPay\Response', $idempotencyKey);
$className = $this->GetObjectForIdempotencyUrl($response->RequestURL);
if (is_null($className) || empty($className) || is_null($response->Resource) || empty($response->Resource))
if (is_null($className) || empty($className) || is_null($response->Resource) || empty($response->Resource)) {
return $response;
}

$response->Resource = $this->CastResponseToEntity($response->Resource, $className);
return $response;
Expand Down
5 changes: 2 additions & 3 deletions MangoPay/ApiUboDeclarations.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ApiUboDeclarations extends Libraries\ApiBase
*/
public function Create($userId)
{

return $this->CreateObject('ubo_declaration_create', null, '\MangoPay\UboDeclaration', $userId);
}

Expand Down Expand Up @@ -53,8 +52,8 @@ public function GetById($uboDeclarationId)
*/
public function CreateUbo($userId, $uboDeclarationId, $ubo)
{
if(is_null($uboDeclarationId ) or empty($uboDeclarationId)){
throw new \MangoPay\Libraries\ResponseException('Parameter uboDeclarationId is empty',400);
if (is_null($uboDeclarationId) or empty($uboDeclarationId)) {
throw new \MangoPay\Libraries\ResponseException('Parameter uboDeclarationId is empty', 400);
}
return $this->SaveObject('ubo_create', $ubo, '\MangoPay\Ubo', $userId, $uboDeclarationId);
}
Expand Down
5 changes: 2 additions & 3 deletions MangoPay/ApiUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function GetAll(& $pagination = null, $sorting = null)
{
$usersList = $this->GetList('users_all', $pagination, null, null, null, $sorting);

$users = array();
$users = [];
if (is_array($usersList)) {
foreach ($usersList as $user) {
array_push($users, $this->GetUserResponse($user));
Expand Down Expand Up @@ -342,8 +342,7 @@ public function CreateKycPageFromFile($userId, $kycDocumentId, $filePath, $idemp
*/
public function GetEMoney($userId, $year = null, $month = null)
{
if ($year == null)
{
if ($year == null) {
$year = $this->GetCurrentYear();
}

Expand Down
1 change: 1 addition & 0 deletions MangoPay/ApiWallets.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand Down
1 change: 1 addition & 0 deletions MangoPay/Autoloader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

spl_autoload_register(function ($class) {

// project-specific namespace prefix
Expand Down
Loading

0 comments on commit 5b5995c

Please sign in to comment.