From 6100d9cfb49256c5ffde336543ba47c7558d8b2d Mon Sep 17 00:00:00 2001 From: Gilmar Pupo Date: Fri, 11 Jan 2019 13:55:04 -0200 Subject: [PATCH] Apply cs fixer --- composer.json | 2 +- src/Client/Client.php | 6 +- src/Console/Command/AbstractCommand.php | 8 +-- src/Entity/Banking/BankingManager.php | 4 +- src/Entity/MovementManager.php | 6 +- .../map/payment-translator-from-native.php | 4 +- src/Translator/map/translate.native.map.php | 64 +++++++++---------- tests/Entity/MovementManagerTest.php | 4 +- tests/TestCaseAbstract.php | 4 +- 9 files changed, 50 insertions(+), 52 deletions(-) diff --git a/composer.json b/composer.json index 35888d7..29ab2c1 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "phpunit/phpunit": "^7.5.1", "symfony/var-dumper": "^4.2.2", - "phpspec/prophecy": "~1.0|dev-master", + "phpspec/prophecy": "^1.0" }, "autoload": { "psr-4": { diff --git a/src/Client/Client.php b/src/Client/Client.php index 29f6283..9141d9a 100644 --- a/src/Client/Client.php +++ b/src/Client/Client.php @@ -28,9 +28,9 @@ final class Client extends ClientAbstract implements ClientInterface public function requestToken() { $pars = [ - 'grant_type' => 'client_credentials', - 'client_id' => $this->getOptions()->get('client_id'), - 'client_secret' => $this->getOptions()->get('client_secret'), + 'grant_type' => 'client_credentials', + 'client_id' => $this->getOptions()->get('client_id'), + 'client_secret' => $this->getOptions()->get('client_secret'), ]; $this->setMode('form'); diff --git a/src/Console/Command/AbstractCommand.php b/src/Console/Command/AbstractCommand.php index f395a16..daee1a8 100644 --- a/src/Console/Command/AbstractCommand.php +++ b/src/Console/Command/AbstractCommand.php @@ -93,7 +93,7 @@ protected function writeInfo(OutputInterface $output, $info, $tabs = '') { $tabs = $tabs."\t"; foreach ($info as $key => $value) { - if (is_array($value)) { + if (\is_array($value)) { $output->writeln(sprintf($tabs.' %s ', $key)); $this->writeInfo($output, $value, $tabs); } else { @@ -122,9 +122,9 @@ protected function saveCredentials(array $data, OutputInterface $output) if (!array_key_exists('refresh_token', $data)) { $output->writeln([ - 'Warning: Offline App', - '- If your App has the option offline_access selected, you will receive a refresh_token along with the access_token', - '- refresh_token is not present', + 'Warning: Offline App', + '- If your App has the option offline_access selected, you will receive a refresh_token along with the access_token', + '- refresh_token is not present', ]); } diff --git a/src/Entity/Banking/BankingManager.php b/src/Entity/Banking/BankingManager.php index af9b19d..632484a 100644 --- a/src/Entity/Banking/BankingManager.php +++ b/src/Entity/Banking/BankingManager.php @@ -78,11 +78,11 @@ public function fillReport(EntityInterface $report) $rac = new Record($translatedLine); if ('initial_available_balance' === $rac->getRecordType()) { $report->addExpand('initial_available_balance', $rac->getExpands()); - } elseif (in_array($rac->getDescription(), ['withdrawal', 'reserve_for_payment'], true)) { + } elseif (\in_array($rac->getDescription(), ['withdrawal', 'reserve_for_payment'], true)) { $report->addExpand($rac->getDescription(), $rac->getExpands()); } elseif (0 === $rac->getSourceId()) { $errors['unknow'][] = $rac->getExpands(); - } elseif (0 === (int)$rac->getGrossAmount()) { + } elseif (0 === (int) $rac->getGrossAmount()) { $errors['gross_amount_zero'][] = $rac->getExpands(); } else { $record = $this->factoryORM($rac, 'Entity\Banking\Report\Record'); diff --git a/src/Entity/MovementManager.php b/src/Entity/MovementManager.php index dddb834..c47f3f9 100644 --- a/src/Entity/MovementManager.php +++ b/src/Entity/MovementManager.php @@ -17,10 +17,7 @@ namespace Gpupo\MercadopagoSdk\Entity; -use Gpupo\Common\Entity\ArrayCollection; - use Gpupo\CommonSchema\ArrayCollection\Banking\Movement\Movement as AC; -use Gpupo\CommonSchema\ORM\Entity\Banking\Movement\Movement; use Gpupo\CommonSdk\Entity\Metadata\MetadataContainer; class MovementManager extends GenericManager @@ -45,8 +42,9 @@ public function getMovementList(): MetadataContainer ->setLimit($list['paging']['limit']) ->setTotalRows($list['paging']['total']); - if(!$list->getResults()){ + if (!$list->getResults()) { $collection->clear(); + return $collection; } diff --git a/src/Entity/map/payment-translator-from-native.php b/src/Entity/map/payment-translator-from-native.php index eb57712..7b4b70a 100644 --- a/src/Entity/map/payment-translator-from-native.php +++ b/src/Entity/map/payment-translator-from-native.php @@ -35,7 +35,7 @@ 'coupon_amount' => 'coupon_amount', 'issuer_id' => 'issuer_id', 'authorization_code' => 'authorization_code', - 'shipping_amount' => 'shipping_cost' + 'shipping_amount' => 'shipping_cost', ] as $origin => $destination) { $foreign[$destination] = $native->get($origin); } @@ -46,7 +46,7 @@ $foreign['marketplace_fee'] = 0.0; foreach ($native->getFeeDetails() as $fee) { - if (in_array($fee['type'], ['ml_fee', 'mp_fee', 'mercadopago_fee'])) { + if (in_array($fee['type'], ['ml_fee', 'mp_fee', 'mercadopago_fee'], true)) { $foreign['marketplace_fee'] += $fee['amount']; } } diff --git a/src/Translator/map/translate.native.map.php b/src/Translator/map/translate.native.map.php index d4b0adb..c241d2b 100644 --- a/src/Translator/map/translate.native.map.php +++ b/src/Translator/map/translate.native.map.php @@ -16,19 +16,19 @@ */ $expands = [ - 'payer' => $native->get('payer'), - 'external_reference' => $native->get('external_reference'), - 'metadata' => $native->get('metadata'), - 'transaction_amount_refunded' => $native->get('transaction_amount_refunded'), - 'transaction_details' => $native->get('transaction_details'), - 'money_release_date' => $native->get('money_release_date'), - 'captured' => $native->get('captured'), - 'card' => $native->get('card'), - 'statement_descriptor' => $native->get('statement_descriptor'), - 'notification_url' => $native->get('notification_url'), - 'refunds' => $native->get('refunds'), - 'order' => $native->get('order'), - ]; + 'payer' => $native->get('payer'), + 'external_reference' => $native->get('external_reference'), + 'metadata' => $native->get('metadata'), + 'transaction_amount_refunded' => $native->get('transaction_amount_refunded'), + 'transaction_details' => $native->get('transaction_details'), + 'money_release_date' => $native->get('money_release_date'), + 'captured' => $native->get('captured'), + 'card' => $native->get('card'), + 'statement_descriptor' => $native->get('statement_descriptor'), + 'notification_url' => $native->get('notification_url'), + 'refunds' => $native->get('refunds'), + 'order' => $native->get('order'), +]; $marketplaceFee = 0; if ($native->get('fee_details')) { @@ -38,25 +38,25 @@ } $array = [ - 'operation_type' => $native->get('operation_type'), - 'payment_number' => $native->get('id'), - 'date_created' => $native->get('date_created'), - 'date_approved' => $native->get('date_approved'), - 'date_last_modified' => $native->get('date_last_updated'), - 'operation_type' => $native->get('operation_type'), - 'expands' => $expands, - 'collector' => $native->get('collector'), - 'reason' => $native->get('description'), - 'marketplace_fee' => $marketplaceFee, - 'currency_id' => $native->get('currency_id'), - 'transaction_amount' => $native->get('transaction_details')['total_paid_amount'], - 'status' => $native->get('status'), - 'status_detail' => $native->get('status_detail'), - 'authorization_code' => $native->get('call_for_authorize_id'), - 'payment_method_id' => $native->get('payment_method_id'), - 'issuer_id' => $native->get('issuer_id'), - 'payment_type' => $native->get('payment_type_id'), - 'installments' => $native->get('installments'), + 'operation_type' => $native->get('operation_type'), + 'payment_number' => $native->get('id'), + 'date_created' => $native->get('date_created'), + 'date_approved' => $native->get('date_approved'), + 'date_last_modified' => $native->get('date_last_updated'), + 'operation_type' => $native->get('operation_type'), + 'expands' => $expands, + 'collector' => $native->get('collector'), + 'reason' => $native->get('description'), + 'marketplace_fee' => $marketplaceFee, + 'currency_id' => $native->get('currency_id'), + 'transaction_amount' => $native->get('transaction_details')['total_paid_amount'], + 'status' => $native->get('status'), + 'status_detail' => $native->get('status_detail'), + 'authorization_code' => $native->get('call_for_authorize_id'), + 'payment_method_id' => $native->get('payment_method_id'), + 'issuer_id' => $native->get('issuer_id'), + 'payment_type' => $native->get('payment_type_id'), + 'installments' => $native->get('installments'), ]; return $array; diff --git a/tests/Entity/MovementManagerTest.php b/tests/Entity/MovementManagerTest.php index 379b795..140696a 100644 --- a/tests/Entity/MovementManagerTest.php +++ b/tests/Entity/MovementManagerTest.php @@ -17,12 +17,12 @@ namespace Gpupo\MercadopagoSdk\Tests\Entity; +use Gpupo\Common\Entity\ArrayCollection; use Gpupo\Common\Entity\Collection; -use Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Payment\Payment; use Gpupo\CommonSchema\ORM\Entity\Banking\Movement\Movement; +use Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Payment\Payment; use Gpupo\MercadopagoSdk\Tests\TestCaseAbstract; use Symfony\Component\Yaml\Yaml; -use Gpupo\Common\Entity\ArrayCollection; /** * @coversDefaultClass \Gpupo\MercadopagoSdk\Entity\MovementManager diff --git a/tests/TestCaseAbstract.php b/tests/TestCaseAbstract.php index bf3dc53..230bfa7 100644 --- a/tests/TestCaseAbstract.php +++ b/tests/TestCaseAbstract.php @@ -26,12 +26,12 @@ abstract class TestCaseAbstract extends CommonSdkTestCaseAbstract public static function getResourcesPath() { - return dirname(__DIR__).'/Resources/'; + return \dirname(__DIR__).'/Resources/'; } public static function getVarPath() { - return dirname(__DIR__).'/var/'; + return \dirname(__DIR__).'/var/'; } public function factoryClient()