Skip to content

Commit b64030e

Browse files
committed
the codestyle of the project for a more modern standard
1 parent 4f58c83 commit b64030e

File tree

107 files changed

+5376
-4823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5376
-4823
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ charset = utf-8
55
end_of_line = lf
66
insert_final_newline = true
77
indent_style = space
8-
indent_size = 2
8+
indent_size = 4
99
trim_trailing_whitespace = true
1010

1111
[*.md]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.idea
22
.tags
33
.tags1
4+
/vendor
5+
/composer.lock
6+
/.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$rules = [
7+
'array_syntax' => ['syntax' => 'short'],
8+
'binary_operator_spaces' => [
9+
'default' => 'single_space',
10+
'operators' => ['=>' => null],
11+
],
12+
'blank_line_after_namespace' => true,
13+
'blank_line_after_opening_tag' => true,
14+
'blank_line_before_statement' => [
15+
'statements' => ['return'],
16+
],
17+
'braces' => true,
18+
'cast_spaces' => true,
19+
'class_attributes_separation' => [
20+
'elements' => ['method' => 'one'],
21+
],
22+
'class_definition' => true,
23+
'concat_space' => [
24+
'spacing' => 'one',
25+
],
26+
'declare_equal_normalize' => true,
27+
'elseif' => true,
28+
'encoding' => true,
29+
'full_opening_tag' => true,
30+
'fully_qualified_strict_types' => true,
31+
'function_declaration' => [
32+
'closure_function_spacing' => 'one',
33+
],
34+
'function_typehint_space' => true,
35+
'heredoc_to_nowdoc' => true,
36+
'include' => true,
37+
'increment_style' => ['style' => 'post'],
38+
'indentation_type' => true,
39+
'linebreak_after_opening_tag' => true,
40+
'line_ending' => true,
41+
'lowercase_cast' => true,
42+
'constant_case' => true,
43+
'lowercase_keywords' => true,
44+
'lowercase_static_reference' => true,
45+
'magic_method_casing' => true,
46+
'magic_constant_casing' => true,
47+
'method_argument_space' => true,
48+
'native_function_casing' => true,
49+
'no_extra_blank_lines' => [
50+
'tokens' => [
51+
'extra',
52+
'throw',
53+
'use',
54+
],
55+
],
56+
'no_blank_lines_after_class_opening' => true,
57+
'no_blank_lines_after_phpdoc' => true,
58+
'no_closing_tag' => true,
59+
'no_empty_phpdoc' => true,
60+
'no_empty_statement' => true,
61+
'no_leading_import_slash' => true,
62+
'no_leading_namespace_whitespace' => true,
63+
'no_mixed_echo_print' => [
64+
'use' => 'echo',
65+
],
66+
'no_multiline_whitespace_around_double_arrow' => true,
67+
'multiline_whitespace_before_semicolons' => [
68+
'strategy' => 'no_multi_line',
69+
],
70+
'no_short_bool_cast' => true,
71+
'no_singleline_whitespace_before_semicolons' => true,
72+
'no_spaces_after_function_name' => true,
73+
'no_spaces_around_offset' => true,
74+
'no_spaces_inside_parenthesis' => true,
75+
'no_trailing_comma_in_list_call' => true,
76+
'no_trailing_comma_in_singleline_array' => true,
77+
'no_trailing_whitespace' => true,
78+
'no_trailing_whitespace_in_comment' => true,
79+
'no_unneeded_control_parentheses' => true,
80+
'no_useless_return' => true,
81+
'no_whitespace_before_comma_in_array' => true,
82+
'no_whitespace_in_blank_line' => true,
83+
'normalize_index_brace' => true,
84+
'not_operator_with_successor_space' => true,
85+
'object_operator_without_whitespace' => true,
86+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
87+
'phpdoc_indent' => true,
88+
'general_phpdoc_tag_rename' => true,
89+
'phpdoc_inline_tag_normalizer' => true,
90+
'phpdoc_tag_type' => true,
91+
'phpdoc_no_access' => true,
92+
'phpdoc_no_package' => true,
93+
'phpdoc_no_useless_inheritdoc' => true,
94+
'phpdoc_scalar' => true,
95+
'phpdoc_single_line_var_spacing' => true,
96+
'phpdoc_summary' => true,
97+
'phpdoc_to_comment' => true,
98+
'phpdoc_trim' => true,
99+
'phpdoc_types' => true,
100+
'phpdoc_var_without_name' => true,
101+
'short_scalar_cast' => true,
102+
'simplified_null_return' => false,
103+
'single_blank_line_at_eof' => true,
104+
'single_blank_line_before_namespace' => true,
105+
'single_class_element_per_statement' => true,
106+
'single_import_per_statement' => true,
107+
'single_line_after_imports' => true,
108+
'single_line_comment_style' => [
109+
'comment_types' => ['hash'],
110+
],
111+
'single_quote' => true,
112+
'space_after_semicolon' => true,
113+
'standardize_not_equals' => true,
114+
'switch_case_semicolon_to_colon' => true,
115+
'switch_case_space' => true,
116+
'ternary_operator_spaces' => true,
117+
'trailing_comma_in_multiline' => true,
118+
'trim_array_spaces' => true,
119+
'unary_operator_spaces' => true,
120+
'visibility_required' => [
121+
'elements' => ['method', 'property'],
122+
],
123+
'whitespace_after_comma_in_array' => true,
124+
'no_unused_imports' => true,
125+
'return_type_declaration' => true,
126+
];
127+
128+
$finder = Finder::create()
129+
->in([
130+
__DIR__ . '/lib',
131+
__DIR__ . '/examples',
132+
__DIR__ . '/test/BeGateway'
133+
])
134+
->name('*.php')
135+
->ignoreDotFiles(true)
136+
->ignoreVCS(true);
137+
138+
$config = new Config();
139+
140+
return $config->setFinder($finder)
141+
->setRules($rules)
142+
->setRiskyAllowed(false)
143+
->setUsingCache(true);

BeGateway.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
require __DIR__ . '/vendor/autoload.php';

Readme.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Requirements
66

7-
PHP 5.6/7.0/7.1/7.2/7.3/7.4
7+
PHP >=7.3
88

99
## Test data
1010

@@ -44,24 +44,26 @@ You have to setup values of variables as follows:
4444
This data you will receive from your payment processor.
4545

4646
```php
47-
\BeGateway\Settings::$shopId = 361;
48-
\BeGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';
49-
\BeGateway\Settings::$gatewayBase = 'https://demo-gateway.begateway.com';
50-
\BeGateway\Settings::$checkoutBase = 'https://checkout.begateway.com';
47+
BeGateway\Settings::$shopId = 361;
48+
BeGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';
49+
BeGateway\Settings::$gatewayBase = 'https://demo-gateway.begateway.com';
50+
BeGateway\Settings::$checkoutBase = 'https://checkout.begateway.com';
5151
```
5252

5353
### Hosted payment page
5454

5555
Simple usage looks like:
5656

5757
```php
58+
<?php
59+
5860
require_once __DIR__ . 'PATH_TO_INSTALLED_LIBRARY/lib/BeGateway.php';
59-
\BeGateway\Settings::$shopId = 361;
60-
\BeGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';
61+
BeGateway\Settings::$shopId = 361;
62+
BeGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';
6163

62-
\BeGateway\Logger::getInstance()->setLogLevel(\BeGateway\Logger::INFO);
64+
BeGateway\Logger::getInstance()->setLogLevel(BeGateway\Logger::INFO);
6365

64-
$transaction = new \BeGateway\GetPaymentToken;
66+
$transaction = new BeGateway\GetPaymentToken;
6567

6668
$transaction->money->setAmount(1.00);
6769
$transaction->money->setCurrency('EUR');
@@ -95,6 +97,8 @@ if ($response->isSuccess() ) {
9597
Simple usage looks like:
9698

9799
```php
100+
<?php
101+
98102
require_once __DIR__ . 'PATH_TO_INSTALLED_LIBRARY/lib/BeGateway.php';
99103
\BeGateway\Settings::$shopId = 361;
100104
\BeGateway\Settings::$shopKey = 'b8647b68898b084b836474ed8d61ffe117c9a01168d867f24953b776ddcb134d';

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.5.3
1+
5.0.0

composer.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
{
22
"name": "begateway/begateway-api-php",
3-
"description" : "BeGateway PHP API library",
3+
"description": "BeGateway PHP API library",
44
"keywords": [
5-
"bepaid",
6-
"begateway",
7-
"payment processing",
8-
"api"
5+
"bepaid",
6+
"begateway",
7+
"payment processing",
8+
"api"
99
],
10-
"license" : "MIT",
10+
"license": "MIT",
1111
"authors": [
12-
{ "name" : "BeGateway",
13-
"email": "[email protected]"
14-
}
12+
{
13+
"name": "BeGateway",
14+
"email": "[email protected]"
15+
}
1516
],
16-
"require" : {
17-
"php" : ">= 5.6.0",
17+
"require": {
18+
"php": ">=7.3.0",
1819
"ext-curl": "*",
1920
"ext-json": "*",
2021
"ext-mbstring": "*"
2122
},
23+
"require-dev": {
24+
"friendsofphp/php-cs-fixer": "^3.10"
25+
},
2226
"autoload": {
23-
"psr-4": { "BeGateway\\" : "lib/BeGateway" }
27+
"psr-4": {
28+
"BeGateway\\": "lib/"
29+
}
30+
},
31+
"scripts": {
32+
"sniff": [
33+
"./vendor/bin/php-cs-fixer fix -vvv --dry-run --show-progress=dots"
34+
],
35+
"lint": [
36+
"./vendor/bin/php-cs-fixer fix -vvv --show-progress=dots"
37+
]
2438
}
2539
}

examples/authorization.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
require_once __DIR__ . '/../lib/BeGateway.php';
34
require_once __DIR__ . '/test_shop_data.php';
45

5-
\BeGateway\Logger::getInstance()->setLogLevel(\BeGateway\Logger::DEBUG);
6+
BeGateway\Logger::getInstance()->setLogLevel(BeGateway\Logger::DEBUG);
67

7-
$transaction = new \BeGateway\AuthorizationOperation;
8+
$transaction = new BeGateway\AuthorizationOperation;
89

910
$amount = rand(1, 100);
1011

@@ -31,13 +32,11 @@
3132
$transaction->customer->setIp('127.0.0.1');
3233
$transaction->customer->setEmail('[email protected]');
3334

34-
3535
$response = $transaction->submit();
3636

37-
print("Transaction message: " . $response->getMessage() . PHP_EOL);
38-
print("Transaction status: " . $response->getStatus(). PHP_EOL);
37+
echo 'Transaction message: ' . $response->getMessage() . PHP_EOL;
38+
echo 'Transaction status: ' . $response->getStatus() . PHP_EOL;
3939

40-
if ($response->isSuccess() || $response->isFailed() ) {
41-
print("Transaction UID: " . $response->getUid() . PHP_EOL);
40+
if ($response->isSuccess() || $response->isFailed()) {
41+
echo 'Transaction UID: ' . $response->getUid() . PHP_EOL;
4242
}
43-
?>

examples/capture.php

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
require_once __DIR__ . '/../lib/BeGateway.php';
34
require_once __DIR__ . '/test_shop_data.php';
45

5-
\BeGateway\Logger::getInstance()->setLogLevel(\BeGateway\Logger::DEBUG);
6+
BeGateway\Logger::getInstance()->setLogLevel(BeGateway\Logger::DEBUG);
67

7-
$transaction = new \BeGateway\AuthorizationOperation;
8+
$transaction = new BeGateway\AuthorizationOperation;
89

910
$amount = rand(1, 100);
1011

@@ -30,27 +31,25 @@
3031
$transaction->customer->setIp('127.0.0.1');
3132
$transaction->customer->setEmail('[email protected]');
3233

33-
3434
$response = $transaction->submit();
3535

36-
print("Transaction message: " . $response->getMessage() . PHP_EOL);
37-
print("Transaction status: " . $response->getStatus(). PHP_EOL);
36+
echo 'Transaction message: ' . $response->getMessage() . PHP_EOL;
37+
echo 'Transaction status: ' . $response->getStatus() . PHP_EOL;
3838

39-
if ($response->isSuccess() ) {
40-
print("Transaction UID: " . $response->getUid() . PHP_EOL);
41-
print("Trying to Capture transaction " . $response->getUid() . PHP_EOL);
39+
if ($response->isSuccess()) {
40+
echo 'Transaction UID: ' . $response->getUid() . PHP_EOL;
41+
echo 'Trying to Capture transaction ' . $response->getUid() . PHP_EOL;
4242

43-
$capture = new \BeGateway\CaptureOperation;
44-
$capture->setParentUid($response->getUid());
45-
$capture->money->setAmount($transaction->money->getAmount());
43+
$capture = new BeGateway\CaptureOperation;
44+
$capture->setParentUid($response->getUid());
45+
$capture->money->setAmount($transaction->money->getAmount());
4646

47-
$capture_response = $capture->submit();
47+
$capture_response = $capture->submit();
4848

49-
if ($capture_response->isSuccess()) {
50-
print("Captured successfuly. Captured transaction UID " . $capture_response->getUid() . PHP_EOL);
51-
}else{
52-
print("Problem to capture" . PHP_EOL);
53-
print("Capture message: " . $capture_response->getMessage() . PHP_EOL);
54-
}
49+
if ($capture_response->isSuccess()) {
50+
echo 'Captured successfuly. Captured transaction UID ' . $capture_response->getUid() . PHP_EOL;
51+
} else {
52+
echo 'Problem to capture' . PHP_EOL;
53+
echo 'Capture message: ' . $capture_response->getMessage() . PHP_EOL;
54+
}
5555
}
56-
?>

0 commit comments

Comments
 (0)