Skip to content

Commit 6da6494

Browse files
committed
Code cleanup and PSR-2 compatible
Cleanup the code and follow PSR-2 guidelines
1 parent a001f83 commit 6da6494

File tree

5 files changed

+51
-27
lines changed

5 files changed

+51
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.idea
12
/vendor
23
composer.phar
34
composer.lock

config/omnipay.php

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
<?php
22

3-
return array(
3+
return [
44

5-
/** The default gateway name */
6-
'gateway' => 'PayPal_Express',
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Gateway
8+
|--------------------------------------------------------------------------
9+
|
10+
| Here you can specify the gateway that the facade should use by default.
11+
|
12+
*/
13+
'gateway' => env('OMNIPAY_GATEWAY', 'PayPal_Express'),
714

8-
/** The default settings, applied to all gateways */
9-
'defaults' => array(
10-
'testMode' => false,
11-
),
15+
/*
16+
|--------------------------------------------------------------------------
17+
| Default settings
18+
|--------------------------------------------------------------------------
19+
|
20+
| Here you can specify default settings for gateways.
21+
|
22+
*/
23+
'defaults' => [
24+
'testMode' => env('OMNIPAY_TESTMODE', false),
25+
],
1226

13-
/** Gateway specific parameters */
14-
'gateways' => array(
15-
'PayPal_Express' => array(
16-
'username' => '',
17-
'landingPage' => array('billing', 'login'),
18-
),
19-
),
27+
/*
28+
|--------------------------------------------------------------------------
29+
| Gateway specific settings
30+
|--------------------------------------------------------------------------
31+
|
32+
| Here you can specify gateway specific settings.
33+
|
34+
*/
35+
'gateways' => [
36+
'PayPal_Express' => [
37+
'username' => env('OMNIPAY_PAYPAL_USERNAME'),
38+
'landingPage' => ['billing', 'login'],
39+
],
40+
],
2041

21-
);
42+
];

src/Facade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
use Omnipay\Common\CreditCard;
44

5-
class Facade extends \Illuminate\Support\Facades\Facade {
6-
5+
class Facade extends \Illuminate\Support\Facades\Facade
6+
{
77
/**
88
* @param array $parameters
99
* @return CreditCard
@@ -16,6 +16,8 @@ public static function creditCard($parameters = null)
1616
/**
1717
* {@inheritDoc}
1818
*/
19-
protected static function getFacadeAccessor() { return 'omnipay'; }
20-
19+
protected static function getFacadeAccessor()
20+
{
21+
return 'omnipay';
22+
}
2123
}

src/GatewayManager.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
use Omnipay\Common\GatewayFactory;
44

5-
class GatewayManager{
6-
5+
class GatewayManager
6+
{
77
/**
88
* The application instance.
99
*
@@ -45,7 +45,7 @@ public function gateway($class = null)
4545
{
4646
$class = $class ?: $this->getDefaultGateway();
4747

48-
if(!isset($this->gateways[$class])){
48+
if (!isset($this->gateways[$class])) {
4949
$gateway = $this->factory->create($class, null, $this->app['request']);
5050
$gateway->initialize($this->getConfig($class));
5151
$this->gateways[$class] = $gateway;
@@ -61,7 +61,7 @@ protected function getConfig($name)
6161
{
6262
return array_merge(
6363
$this->defaults,
64-
$this->app['config']->get('omnipay.gateways.'.$name, array())
64+
$this->app['config']->get('omnipay.gateways.'.$name, [])
6565
);
6666
}
6767

@@ -95,7 +95,6 @@ public function setDefaultGateway($name)
9595
*/
9696
public function __call($method, $parameters)
9797
{
98-
return call_user_func_array(array($this->gateway(), $method), $parameters);
98+
return call_user_func_array([$this->gateway(), $method], $parameters);
9999
}
100-
101100
}

src/ServiceProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use Omnipay\Common\GatewayFactory;
44

5-
class ServiceProvider extends \Illuminate\Support\ServiceProvider {
5+
class ServiceProvider extends \Illuminate\Support\ServiceProvider
6+
{
67

78
/**
89
* Indicates if loading of the provider is deferred.
@@ -21,7 +22,7 @@ public function register()
2122
$configPath = __DIR__ . '/../config/omnipay.php';
2223
$this->publishes([$configPath => config_path('omnipay.php')]);
2324

24-
$this->app->singleton('omnipay',function ($app){
25+
$this->app->singleton('omnipay', function ($app) {
2526
$defaults = $app['config']->get('omnipay.defaults', array());
2627
return new GatewayManager($app, new GatewayFactory, $defaults);
2728
});

0 commit comments

Comments
 (0)