Skip to content

Commit 166b46f

Browse files
committed
Optimize code
1 parent a27ea1a commit 166b46f

File tree

7 files changed

+378
-95
lines changed

7 files changed

+378
-95
lines changed

.travis.yml

Lines changed: 90 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,121 @@
1-
sudo: false
2-
31
language: php
4-
2+
sudo: false
3+
dist: trusty
54
cache:
65
directories:
76
- $HOME/.composer/cache
87

98
env:
109
global:
11-
- COVERAGE=1 XDEBUG=0
10+
- COVERAGE=1
1211

1312
matrix:
1413
include:
1514
- php: 5.5
16-
env: LARAVEL_VERSION=5.2.*
15+
env:
16+
- PHPUNIT_VERSION=^4.8
17+
- LARAVEL_VERSION=5.2.*
1718
- php: 5.6
18-
env: LARAVEL_VERSION=5.2.*
19+
env:
20+
- COVERAGE=1 XDEBUG=1
21+
- PHPUNIT_VERSION=^5.7
22+
- LARAVEL_VERSION=5.2.*
1923
- php: 5.6
20-
env: LARAVEL_VERSION=5.2.*
24+
env:
25+
- COVERAGE=1 XDEBUG=1
26+
- PHPUNIT_VERSION=^5.7
27+
- LARAVEL_VERSION=5.3.*
2128
- php: 5.6
22-
env: LARAVEL_VERSION=5.3.*
23-
- php: 5.6
24-
env: LARAVEL_VERSION=5.4.*
25-
- php: hhvm
26-
env: XDEBUG=1 LARAVEL_VERSION=5.4.*
29+
env:
30+
- COVERAGE=1 XDEBUG=1
31+
- PHPUNIT_VERSION=^5.7
32+
- LARAVEL_VERSION=5.4.*
2733
- php: 7.0
28-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.4.*
29-
- php: 7.1
30-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.4.*
31-
- php: 7.2
32-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.4.*
34+
env:
35+
- COVERAGE=1 XDEBUG=1
36+
- PHPUNIT_VERSION=^5.7
37+
- LARAVEL_VERSION=5.4.*
3338
- php: 7.0
34-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.5.*
39+
env:
40+
- COVERAGE=1 XDEBUG=1
41+
- PHPUNIT_VERSION=^5.7
42+
- LARAVEL_VERSION=5.5.*
3543
- php: 7.1
36-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.5.*
44+
env:
45+
- COVERAGE=1 XDEBUG=1
46+
- PHPUNIT_VERSION=^7.5
47+
- LARAVEL_VERSION=5.5.*
48+
- php: 7.1
49+
env:
50+
- COVERAGE=1 XDEBUG=1
51+
- PHPUNIT_VERSION=^7.5
52+
- LARAVEL_VERSION=5.6.*
53+
- php: 7.1
54+
env:
55+
- COVERAGE=1 XDEBUG=1
56+
- PHPUNIT_VERSION=^7.5
57+
- LARAVEL_VERSION=5.7.*
58+
- php: 7.1
59+
env:
60+
- COVERAGE=1 XDEBUG=1
61+
- PHPUNIT_VERSION=^7.5
62+
- LARAVEL_VERSION=5.8.*
63+
- php: 7.2
64+
env:
65+
- COVERAGE=1 XDEBUG=1
66+
- PHPUNIT_VERSION=^7.5
67+
- LARAVEL_VERSION=5.5.*
68+
- php: 7.2
69+
env:
70+
- COVERAGE=1 XDEBUG=1
71+
- PHPUNIT_VERSION=^7.5
72+
- LARAVEL_VERSION=5.6.*
73+
- php: 7.2
74+
env:
75+
- COVERAGE=1 XDEBUG=1
76+
- PHPUNIT_VERSION=^7.5
77+
- LARAVEL_VERSION=5.7.*
3778
- php: 7.2
38-
env: COVERAGE=1 XDEBUG=1 LARAVEL_VERSION=5.5.*
79+
env:
80+
- COVERAGE=1 XDEBUG=1
81+
- PHPUNIT_VERSION=^7.5
82+
- LARAVEL_VERSION=5.8.*
83+
- php: 7.3
84+
env:
85+
- COVERAGE=1 XDEBUG=1
86+
- PHPUNIT_VERSION=^8.0
87+
- LARAVEL_VERSION=5.5.*
88+
- php: 7.3
89+
env:
90+
- COVERAGE=1 XDEBUG=1
91+
- PHPUNIT_VERSION=^8.0
92+
- LARAVEL_VERSION=5.6.*
93+
- php: 7.3
94+
env:
95+
- COVERAGE=1 XDEBUG=1
96+
- PHPUNIT_VERSION=^8.0
97+
- LARAVEL_VERSION=5.7.*
98+
- php: 7.3
99+
env:
100+
- COVERAGE=1 XDEBUG=1
101+
- PHPUNIT_VERSION=^8.0
102+
- LARAVEL_VERSION=5.8.*
39103
fast_finish: true
40104
allow_failures:
41105
- php: 7.0
42106
- php: 7.1
43107
- php: 7.2
108+
- php: 7.3
44109

45110
before_script:
46-
- travis_retry composer self-update
111+
- curl --version
112+
- travis_retry composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update -n
47113
- travis_retry composer require "laravel/framework:${LARAVEL_VERSION}" --no-interaction --prefer-source --dev
114+
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" || "$TRAVIS_PHP_VERSION" != "7.1" ]]; then echo "xdebug.overload_var_dump = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini || true; fi
48115

49116
script:
50-
- composer test:ci
117+
- if [ "$TRAVIS_PHP_VERSION" != "7.1" ]; then vendor/bin/phpunit; fi
118+
- if [ "$TRAVIS_PHP_VERSION" == "7.1" ]; then vendor/bin/phpunit --verbose --coverage-text --coverage-clover build/logs/clover.xml; fi
51119

52120
after_success:
53121
bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Seluruh fitur, method, property pada Laravel PHP library ini seluruhnya sama den
3838
* [Mutasi Rekening](https://github.com/odenktools/laravel-bca#account-statement)
3939
* [Info Kurs](https://github.com/odenktools/laravel-bca#foreign-exchange-rate)
4040
* [Pencarian ATM Terdekat](https://github.com/odenktools/laravel-bca#nearest-atm-locator)
41-
* [Deposit Rate](https://github.com/odenktools/php-bca#deposit-rate)
42-
* [Generate Signature](https://github.com/odenktools/php-bca#generate-signature)
43-
* [How to contribute](https://github.com/odenktools/php-bca#how-to-contribute)
41+
* [Deposit Rate](https://github.com/odenktools/laravel-bca#deposit-rate)
42+
* [Generate Signature](https://github.com/odenktools/laravel-bca#generate-signature)
43+
* [How to contribute](https://github.com/odenktools/laravel-bca#how-to-contribute)
4444

4545
### INSTALASI
4646

@@ -254,6 +254,19 @@ Saat berguna untuk keperluan testing.
254254
echo $authSignature;
255255
```
256256

257+
# Test
258+
259+
**Using Composer**
260+
261+
```bash
262+
composer run-script test:ci
263+
```
264+
265+
**Using PHPUnit**
266+
267+
```bash
268+
vendor/bin/phpunit --verbose --coverage-text
269+
```
257270

258271
# How to contribute
259272

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
"require": {
1414
"php": "^5.5.9 || ^5.6.4 || ^7.0",
1515
"ext-curl": "*",
16-
"illuminate/contracts": "5.2.* || 5.3.* || 5.4.* || 5.5.*",
17-
"illuminate/support": "5.2.* || 5.3.* || 5.4.* || 5.5.*",
18-
"illuminate/validation": "5.2.* || 5.3.* || 5.4.* || 5.5.*",
16+
"illuminate/contracts": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
17+
"illuminate/support": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
18+
"illuminate/validation": "5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*",
1919
"graham-campbell/manager": "^2.4 || ^3.0",
2020
"odenktools/php-bca": "2.*"
2121
},
2222
"require-dev": {
2323
"graham-campbell/testbench": "3.2.*|3.3.*|3.4.*|3.5.*",
2424
"mockery/mockery": "^0.9.5 || ~1.0",
25-
"phpunit/phpunit": "~4.0 || ^5.4 || ~6.0"
25+
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0"
2626
},
2727
"autoload": {
2828
"psr-4": {

phpunit.xml.dist

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,22 @@
1515
stopOnFailure="false"
1616
verbose="true">
1717
<testsuites>
18-
<testsuite name="Laravel Bca Suite">
19-
<directory suffix="Test.php">./tests</directory>
20-
</testsuite>
18+
<testsuite name="Laravel Bca Suite">
19+
<directory suffix="Test.php">./tests</directory>
20+
</testsuite>
2121
</testsuites>
2222

2323
<filter>
24-
<whitelist processUncoveredFilesFromWhitelist="true">
25-
<directory suffix=".php">./src</directory>
26-
</whitelist>
24+
<whitelist processUncoveredFilesFromWhitelist="true">
25+
<directory suffix=".php">./src</directory>
26+
</whitelist>
2727
</filter>
2828

29-
<logging>
30-
<log type="tap" target="build/report.tap"/>
31-
<log type="junit" target="build/report.junit.xml"/>
32-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
33-
<log type="coverage-text" target="build/coverage.txt"/>
34-
<log type="coverage-clover" target="build/logs/clover.xml"/>
35-
</logging>
29+
<logging>
30+
<log type="junit" target="build/report.junit.xml"/>
31+
<log type="coverage-html" target="build/coverage"/>
32+
<log type="coverage-text" target="build/coverage.txt"/>
33+
<log type="coverage-clover" target="build/logs/clover.xml"/>
34+
</logging>
3635

3736
</phpunit>

src/BcaFactory.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,35 @@ class BcaFactory
1818
* Create a new BcaHttp client.
1919
*
2020
* @param array $config
21+
* @param array $options optional parameter
2122
*
2223
* @return \BcaHttp
2324
*/
24-
public function make(array $config)
25+
public function make(array $config, $options = [])
2526
{
26-
$config = $this->getConfig($config);
27+
$config = $this->getConfig($config, $options);
2728

28-
return $this->getClient($config);
29+
return $this->getClient($config, $options);
2930
}
3031

3132
/**
3233
* Get the configuration data.
3334
*
3435
* @param string[] $config
36+
* @param array $options optional parameter
3537
*
3638
* @throws \InvalidArgumentException
3739
*
3840
* @return array
3941
*/
40-
protected function getConfig(array $config)
42+
protected function getConfig(array $config, $options = array())
4143
{
4244
$keys = [
4345
'corp_id',
4446
'client_id',
4547
'client_secret',
4648
'api_key',
47-
'secret_key',
48-
'scheme',
49-
'port',
50-
'timezone',
51-
'host',
52-
'timeout',
53-
'development',
49+
'secret_key'
5450
];
5551

5652
foreach ($keys as $key) {
@@ -63,20 +59,22 @@ protected function getConfig(array $config)
6359
}
6460

6561
/**
66-
* Get the bca http.
62+
* Get the BCA Http client.
6763
*
6864
* @param string[] $auth
65+
* @param array $options optional parameter
6966
*
7067
* @return \BcaHttp
7168
*/
72-
protected function getClient(array $auth)
69+
protected function getClient(array $auth, $options = [])
7370
{
7471
return new BcaHttp(
7572
$auth['corp_id'],
7673
$auth['client_id'],
7774
$auth['client_secret'],
7875
$auth['api_key'],
79-
$auth['secret_key']
76+
$auth['secret_key'],
77+
$options
8078
);
8179
}
8280
}

src/BcaServiceProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ protected function registerManager()
7878
$this->app->singleton('bca', function (Container $app) {
7979
$config = $app['config'];
8080
$factory = $app['bca.factory'];
81-
8281
return new BcaManager($config, $factory);
8382
});
8483

0 commit comments

Comments
 (0)