From cdc4322d0be402a3a0e5569e2f295db6e25d1c6e Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 15 Dec 2022 23:28:44 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Models/Customer.php | 2 +- src/Paymongo.php | 12 ++++----- src/Traits/Request.php | 49 ++++++++++++++++++++----------------- tests/CustomerTest.php | 10 ++++---- tests/LinkTest.php | 8 +++--- tests/PaymentMethodTest.php | 2 +- tests/PaymentTest.php | 3 +-- tests/Pest.php | 20 +++++++-------- 8 files changed, 55 insertions(+), 51 deletions(-) diff --git a/src/Models/Customer.php b/src/Models/Customer.php index 26d6725..f72cfa7 100644 --- a/src/Models/Customer.php +++ b/src/Models/Customer.php @@ -2,8 +2,8 @@ namespace Luigel\Paymongo\Models; -use Luigel\Paymongo\Paymongo; use Illuminate\Support\Collection; +use Luigel\Paymongo\Paymongo; class Customer extends BaseModel { diff --git a/src/Paymongo.php b/src/Paymongo.php index c853c9a..4c2321f 100644 --- a/src/Paymongo.php +++ b/src/Paymongo.php @@ -2,17 +2,17 @@ namespace Luigel\Paymongo; +use Luigel\Paymongo\Models\Customer; use Luigel\Paymongo\Models\Link; -use Luigel\Paymongo\Models\Token; -use Luigel\Paymongo\Models\Refund; -use Luigel\Paymongo\Models\Source; use Luigel\Paymongo\Models\Payment; -use Luigel\Paymongo\Models\Webhook; -use Luigel\Paymongo\Traits\Request; -use Luigel\Paymongo\Models\Customer; use Luigel\Paymongo\Models\PaymentIntent; use Luigel\Paymongo\Models\PaymentMethod; +use Luigel\Paymongo\Models\Refund; +use Luigel\Paymongo\Models\Source; +use Luigel\Paymongo\Models\Token; +use Luigel\Paymongo\Models\Webhook; use Luigel\Paymongo\Traits\HasToggleWebhook; +use Luigel\Paymongo\Traits\Request; class Paymongo { diff --git a/src/Traits/Request.php b/src/Traits/Request.php index 81bec2e..d156eb3 100644 --- a/src/Traits/Request.php +++ b/src/Traits/Request.php @@ -4,18 +4,18 @@ use Exception; use GuzzleHttp\Client; -use Luigel\Paymongo\Models\Link; -use Illuminate\Support\Collection; -use Luigel\Paymongo\Models\Webhook; -use Luigel\Paymongo\Models\Customer; -use Luigel\Paymongo\Models\BaseModel; use GuzzleHttp\Exception\ClientException; -use Luigel\Paymongo\Models\PaymentIntent; -use Luigel\Paymongo\Exceptions\NotFoundException; +use Illuminate\Support\Collection; +use Luigel\Paymongo\Exceptions\AmountTypeNotSupportedException; use Luigel\Paymongo\Exceptions\BadRequestException; +use Luigel\Paymongo\Exceptions\NotFoundException; use Luigel\Paymongo\Exceptions\PaymentErrorException; use Luigel\Paymongo\Exceptions\UnauthorizedException; -use Luigel\Paymongo\Exceptions\AmountTypeNotSupportedException; +use Luigel\Paymongo\Models\BaseModel; +use Luigel\Paymongo\Models\Customer; +use Luigel\Paymongo\Models\Link; +use Luigel\Paymongo\Models\PaymentIntent; +use Luigel\Paymongo\Models\Webhook; trait Request { @@ -146,9 +146,10 @@ public function attach(PaymentIntent $intent, string $paymentMethodId, string|nu } /** - * Archives the link + * Archives the link. */ - public function archive(Link $link){ + public function archive(Link $link) + { $this->method = 'POST'; $this->apiUrl = $this->apiUrl.$link->id.'/archive'; @@ -163,11 +164,12 @@ public function archive(Link $link){ } /** - * Unarchives the link + * Unarchives the link. */ - public function unarchive(Link $link){ + public function unarchive(Link $link) + { $this->method = 'POST'; - $this->apiUrl = $this->apiUrl . $link->id . '/unarchive'; + $this->apiUrl = $this->apiUrl.$link->id.'/unarchive'; $this->setOptions([ 'headers' => [ @@ -180,11 +182,12 @@ public function unarchive(Link $link){ } /** - * Update the customer information + * Update the customer information. */ - public function updateCustomer(Customer $customer, array $payload){ + public function updateCustomer(Customer $customer, array $payload) + { $this->method = 'PATCH'; - $this->apiUrl = $this->apiUrl . $customer->id; + $this->apiUrl = $this->apiUrl.$customer->id; $this->payload = $payload; $this->formRequestData(); @@ -200,11 +203,12 @@ public function updateCustomer(Customer $customer, array $payload){ } /** - * Delete the customer + * Delete the customer. */ - public function deleteCustomer(Customer $customer){ + public function deleteCustomer(Customer $customer) + { $this->method = 'DELETE'; - $this->apiUrl = $this->apiUrl . $customer->id; + $this->apiUrl = $this->apiUrl.$customer->id; $this->setOptions([ 'headers' => [ @@ -217,11 +221,12 @@ public function deleteCustomer(Customer $customer){ } /** - * Get Customer's Payment Methods + * Get Customer's Payment Methods. */ - public function getPaymentMethods(Customer $customer){ + public function getPaymentMethods(Customer $customer) + { $this->method = 'GET'; - $this->apiUrl = $this->apiUrl . $customer->id . '/payment_methods'; + $this->apiUrl = $this->apiUrl.$customer->id.'/payment_methods'; $this->setOptions([ 'headers' => [ diff --git a/tests/CustomerTest.php b/tests/CustomerTest.php index 0bbf338..8659f66 100644 --- a/tests/CustomerTest.php +++ b/tests/CustomerTest.php @@ -1,9 +1,9 @@ expectException(NotFoundException::class); - + Paymongo::customer() ->find('test'); }); @@ -33,7 +33,7 @@ expect($customer->last_name)->toBe('Felix'); $updatedCustomer = $customer->update([ - 'last_name' => 'Mongo' + 'last_name' => 'Mongo', ]); expect($updatedCustomer->last_name)->toBe('Mongo'); @@ -49,4 +49,4 @@ $customer = createCustomer()->paymentMethods(); expect($customer)->toBeInstanceOf(Collection::class); -}); \ No newline at end of file +}); diff --git a/tests/LinkTest.php b/tests/LinkTest.php index a754bcc..b260a60 100644 --- a/tests/LinkTest.php +++ b/tests/LinkTest.php @@ -1,8 +1,8 @@ expectException(NotFoundException::class); - + Paymongo::link() ->find('test'); }); @@ -46,4 +46,4 @@ $unarchivedLink = $archivedLink->unarchive(); expect($unarchivedLink->archived)->toBe(false); -}); \ No newline at end of file +}); diff --git a/tests/PaymentMethodTest.php b/tests/PaymentMethodTest.php index d75b2bd..d461de5 100644 --- a/tests/PaymentMethodTest.php +++ b/tests/PaymentMethodTest.php @@ -56,4 +56,4 @@ ->toBeInstanceOf(PaymentMethod::class) ->type->toBe('payment_method') ->payment_method_type->toBe('paymaya'); -}); \ No newline at end of file +}); diff --git a/tests/PaymentTest.php b/tests/PaymentTest.php index 564c24a..648ac10 100644 --- a/tests/PaymentTest.php +++ b/tests/PaymentTest.php @@ -1,7 +1,6 @@ currency->toBe('PHP') ->statement_descriptor->toBe('LUIGEL STORE') ->status->toBe('paid'); -}); \ No newline at end of file +}); diff --git a/tests/Pest.php b/tests/Pest.php index 96a850b..adfa3dc 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,16 +1,16 @@ in(__DIR__); @@ -145,7 +145,7 @@ function createLink(): Link return Paymongo::link()->create([ 'amount' => 100.00, 'description' => 'Link Test', - 'remarks' => 'laravel-paymongo' + 'remarks' => 'laravel-paymongo', ]); } @@ -154,9 +154,9 @@ function createCustomer(): Customer return Paymongo::customer()->create([ 'first_name' => 'Gringiemar', 'last_name' => 'Felix', - 'phone' => '+6391234' . rand(10000, 99999), - 'email' => 'customer' . Str::random(8) . rand(0, 100) . '@email.com', - 'default_device' => 'phone' + 'phone' => '+6391234'.rand(10000, 99999), + 'email' => 'customer'.Str::random(8).rand(0, 100).'@email.com', + 'default_device' => 'phone', ]); }