Skip to content

Commit

Permalink
cleanup soapclient constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Anderson committed Sep 9, 2015
1 parent 5ac580c commit 1309e5f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
19 changes: 4 additions & 15 deletions src/Credibility/LaravelCybersource/SOAPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@

use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient;
use Credibility\LaravelCybersource\Exceptions\CybersourceException;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;

class SOAPClient extends BeSimpleSoapClient {

/**
* @var Illuminate\Foundation\Application
*/
public static $app;

const DOM_VERSION = '1.0';
Expand All @@ -31,19 +24,15 @@ class SOAPClient extends BeSimpleSoapClient {
* Constructs a client off of the
* configured WSDL
*/
public function __construct(Application $app, $options = null)
public function __construct($app, array $options = [])
{
static::$app = $app;

$this->wsdl = static::$app->make('config')->get('laravel-cybersource::wsdl_endpoint');
$this->merchantId = static::$app->make('config')->get('laravel-cybersource::merchant_id');
$this->transactionId = static::$app->make('config')->get('laravel-cybersource::transaction_id');

if(is_null($options)) {
parent::__construct($this->wsdl);
} else {
parent::__construct($this->wsdl, $options);
}
parent::__construct($this->wsdl, $options);
}

public function addWSSEToken()
Expand All @@ -70,10 +59,10 @@ public function addWSSEToken()

/**
* Static getInstance Method for updating SOAP options
* @param null $options
* @param array $options
* @return SOAPClient
*/
public static function getInstance($options = null)
public static function getInstance(array $options = [])
{
$factory = new SOAPClientFactory(static::$app);
return $factory->getInstance($options);
Expand Down
5 changes: 2 additions & 3 deletions src/Credibility/LaravelCybersource/SOAPClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

class SOAPClientFactory {

/** @var Illuminate\Foundation\Application */
protected $app;

public function __construct(Application $app)
public function __construct($app)
{
$this->app = $app;
}
Expand All @@ -17,7 +16,7 @@ public function __construct(Application $app)
* @param null $options
* @return SOAPClient
*/
public function getInstance($options = null)
public function getInstance(array $options = [])
{
return new SOAPClient($this->app, $options);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Credibility/LaravelCybersource/SOAPRequester.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ public function send(CybersourceSOAPModel $request)

public function convertToStdClass(CybersourceSOAPModel $request)
{
$contextOpts = array(
'http' => array(
$contextOpts = [
'http' => [
'timeout' => $this->timeout
)
);
]
];

$context = stream_context_create($contextOpts);

$soapOts = array(
$soapOts = [
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
'encoding' => 'utf-8',
'exceptions' => true,
'connection_timeout' => $this->timeout,
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_MEMORY
);
];

try {
$this->soapClient = $this->clientFactory->getInstance($soapOts);
Expand Down
2 changes: 1 addition & 1 deletion tests/SOAPClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SOAPClientTest extends TestCase {
public function setUp()
{
parent::setUp();
$this->client = new SOAPClient($this->mockApp, null);
$this->client = new SOAPClient($this->mockApp);
}

public function testConstruct()
Expand Down

0 comments on commit 1309e5f

Please sign in to comment.