Skip to content

Commit ae2a93f

Browse files
committed
PAYH-14: feat: adding pint
1 parent b5de3bc commit ae2a93f

15 files changed

+174
-36
lines changed

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./vendor/bin/pint

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
}
1414
],
1515
"require-dev": {
16-
"pestphp/pest": "^3.5"
16+
"pestphp/pest": "^3.5",
17+
"laravel/pint": "^1.18"
1718
},
1819
"config": {
1920
"allow-plugins": {
@@ -27,4 +28,4 @@
2728
"scripts": {
2829
"test": "vendor/bin/pest"
2930
}
30-
}
31+
}

composer.lock

+67-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/asaas/clients.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22

3-
use PHPay\PHPay;
43
use PHPay\Gateways\Asaas\AsaasGateway;
4+
use PHPay\PHPay;
55

66
require_once __DIR__ . '/../../vendor/autoload.php';
7+
78
require_once __DIR__ . '/credentials.php';
89

910
$client = [
10-
'name' => NAME,
11-
'cpf_cnpj' => CPF_CNPJ
11+
'name' => NAME,
12+
'cpf_cnpj' => CPF_CNPJ,
1213
];
1314

1415
/**
@@ -35,7 +36,7 @@
3536
*/
3637
$response = $phpay
3738
->client()
38-
->with(['cpfCnpj' => '09102295466',])
39+
->with(['cpfCnpj' => '09102295466', ])
3940
->all();
4041

4142
// print_r($response);

examples/asaas/credentials.example.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
const TOKEN_ASAAS_SANDBOX = '';
44

55
/* client to testing */
6-
const NAME = '';
6+
const NAME = '';
77
const CPF_CNPJ = '';

pint.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"preset": "psr12",
3+
"rules": {
4+
"group_import": true,
5+
"single_import_per_statement": false,
6+
"no_unused_imports": true,
7+
"array_indentation": true,
8+
"array_syntax": {
9+
"syntax": "short"
10+
},
11+
"binary_operator_spaces": {
12+
"default": "single_space",
13+
"operators": {
14+
"=": "align_single_space_minimal",
15+
"=>": "align_single_space_minimal"
16+
}
17+
},
18+
"blank_line_after_namespace": true,
19+
"blank_line_after_opening_tag": false,
20+
"class_attributes_separation": {
21+
"elements": {
22+
"property": "one"
23+
}
24+
},
25+
"concat_space": {
26+
"spacing": "one"
27+
},
28+
"declare_equal_normalize": {
29+
"space": "single"
30+
},
31+
"elseif": false,
32+
"encoding": true,
33+
"indentation_type": true,
34+
"no_useless_else": false,
35+
"no_useless_return": true,
36+
"ordered_imports": true,
37+
"ternary_operator_spaces": true,
38+
"no_extra_blank_lines": true,
39+
"no_multiline_whitespace_around_double_arrow": true,
40+
"multiline_whitespace_before_semicolons": true,
41+
"no_singleline_whitespace_before_semicolons": true,
42+
"no_spaces_around_offset": true,
43+
"ternary_to_null_coalescing": true,
44+
"whitespace_after_comma_in_array": true,
45+
"trim_array_spaces": true,
46+
"trailing_comma_in_multiline": true,
47+
"unary_operator_spaces": true,
48+
"blank_line_before_statement": {
49+
"statements": [
50+
"break",
51+
"continue",
52+
"declare",
53+
"return",
54+
"throw",
55+
"try",
56+
"continue",
57+
"do",
58+
"exit",
59+
"for",
60+
"foreach",
61+
"if",
62+
"include",
63+
"include_once",
64+
"require",
65+
"require_once"
66+
]
67+
}
68+
}
69+
}

src/Gateways/Asaas/AsaasGateway.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Support\Facades\Http;
66
use PHPay\Contracts\GatewayInterface;
77
use PHPay\Exceptions\AsaasExceptions;
8-
use PHPay\Gateways\Asaas\Enums\{BillingType, ClientMethods};
8+
use PHPay\Gateways\Asaas\Enums\{BillingType};
99
use PHPay\Gateways\Asaas\Requests\AsaasPixRequest;
1010
use PHPay\Gateways\Asaas\Resources\{Auth, Client};
1111
use PHPay\Gateways\Gateway;
@@ -58,10 +58,10 @@ public function pix(array $pix): self|AsaasExceptions
5858

5959
$payment = Http::asaas()
6060
->post('/payments', [
61-
'customer' => $this->customerId,
61+
'customer' => $this->customerId,
6262
'billingType' => BillingType::PIX->value,
63-
'value' => $amount,
64-
'dueDate' => $due_date,
63+
'value' => $amount,
64+
'dueDate' => $due_date,
6565
'description' => $description,
6666
])->json();
6767

src/Gateways/Asaas/Enums/BillingType.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
enum BillingType: string
66
{
7-
case UNDEFINED = 'UNDEFINED';
8-
case BOLETO = 'BOLETO';
7+
case UNDEFINED = 'UNDEFINED';
8+
case BOLETO = 'BOLETO';
99
case CREDIT_CARD = 'CREDIT_CARD';
10-
case PIX = 'PIX';
10+
case PIX = 'PIX';
1111
}

src/Gateways/Asaas/Enums/ClientMethods.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
enum ClientMethods: string
66
{
7-
case ALL = 'all';
8-
case FIND = 'find';
9-
case STORE = 'store';
7+
case ALL = 'all';
8+
case FIND = 'find';
9+
case STORE = 'store';
1010
case UPDATE = 'update';
1111
case DELETE = 'delete';
1212
}

src/Gateways/Asaas/Requests/AsaasClientRequest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class AsaasClientRequest
1414
*/
1515
public static function validate(array $client): void
1616
{
17-
if (! isset($client['name'])) {
17+
if (!isset($client['name'])) {
1818
throw new \InvalidArgumentException(self::messages()->name);
1919
}
2020

21-
if (! isset($client['cpf_cnpj'])) {
21+
if (!isset($client['cpf_cnpj'])) {
2222
throw new \InvalidArgumentException(self::messages()->cpf_cnpj);
2323
}
2424
}
@@ -31,7 +31,7 @@ public static function validate(array $client): void
3131
public function messages(): stdClass
3232
{
3333
return (object) [
34-
'name' => 'Asaas: Nome do cliente é obrigatório para o Asaas',
34+
'name' => 'Asaas: Nome do cliente é obrigatório para o Asaas',
3535
'cpf_cnpj' => 'Asaas: CPF/CNPJ do cliente é obrigatório para o Asaas',
3636
];
3737
}

src/Gateways/Asaas/Requests/AsaasPixRequest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class AsaasPixRequest
88
{
99
public static function validate(array $pix): void
1010
{
11-
if (! isset($pix['description'])) {
11+
if (!isset($pix['description'])) {
1212
throw new \InvalidArgumentException(self::messages()->description);
1313
}
1414

15-
if (! isset($pix['amount'])) {
15+
if (!isset($pix['amount'])) {
1616
throw new \InvalidArgumentException(self::messages()->amount);
1717
}
1818

19-
if (! isset($pix['due_date'])) {
19+
if (!isset($pix['due_date'])) {
2020
throw new \InvalidArgumentException(self::messages()->due_date->required);
2121
}
2222

@@ -29,10 +29,10 @@ public static function messages(): stdClass
2929
{
3030
return (object) [
3131
'description' => 'Asaas: Descrição do pagamento é obrigatório para o Asaas',
32-
'amount' => 'Asaas: Valor do pagamento é obrigatório para o Asaas',
33-
'due_date' => (object) [
32+
'amount' => 'Asaas: Valor do pagamento é obrigatório para o Asaas',
33+
'due_date' => (object) [
3434
'required' => 'Asaas: Data de vencimento do pagamento é obrigatório para o Asaas',
35-
'date' => 'Asaas: Data de vencimento do pagamento não pode ser menor que a data atual',
35+
'date' => 'Asaas: Data de vencimento do pagamento não pode ser menor que a data atual',
3636
],
3737
];
3838
}

src/Gateways/Asaas/Resources/Auth.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace PHPay\Gateways\Asaas\Resources;
44

55
use Illuminate\Support\Facades\Http;
6-
use PHPay\Exceptions\AsaasExceptions;
76

87
final class Auth
98
{
@@ -24,7 +23,7 @@ public function __construct(string $token, bool $sandbox)
2423
->baseUrl($baseUrl)
2524
->withHeaders([
2625
'content-type' => 'application/json',
27-
'user-agent' => 'payhub',
26+
'user-agent' => 'payhub',
2827
'access_token' => $token,
2928
]);
3029
});

src/Gateways/Asaas/Resources/Client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class Client implements ClientInterface
3333
*/
3434
public function __construct(array $client, Gateway $gateway)
3535
{
36-
$this->client = $client;
36+
$this->client = $client;
3737
$this->gateway = $gateway;
3838
}
3939

@@ -110,13 +110,13 @@ public function store(): string|AsaasExceptions
110110

111111
$client = self::find($cpf_cnpj);
112112

113-
if (! empty($client)) {
113+
if (!empty($client)) {
114114
return $client[0]['id'];
115115
}
116116

117117
$client = Http::asaas()
118118
->post(env('ASSAS_CLIENTS'), [
119-
'name' => $name,
119+
'name' => $name,
120120
'cpfCnpj' => $cpf_cnpj,
121121
])->json();
122122

src/PHPay.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use Dotenv\Dotenv;
66
use Illuminate\Container\Container;
77
use Illuminate\Http\Client\Factory;
8-
use Illuminate\Support\Facades\Facade;
9-
use Illuminate\Support\Facades\Http;
8+
use Illuminate\Support\Facades\{Facade, Http};
109
use PHPay\Gateways\Asaas\AsaasGateway;
1110
use PHPay\Gateways\Gateway;
1211

tests/Feature/PayhubTest.php renamed to tests/Feature/PHPayTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
use PHPay\PHPay;
44

55
test('instance payhub class', function () {
6-
$payhub = new PHPay('token');
6+
$token = '';
77

8-
expect($payhub)
8+
$phpay = PHPay::asaas($token);
9+
10+
expect($phpay)
911
->toBeInstanceOf(PHPay::class);
1012
});

0 commit comments

Comments
 (0)