From 4315732245f6578b7b61cdf06934e8f8b9819501 Mon Sep 17 00:00:00 2001 From: Fernando Kupper Cardoso Date: Thu, 11 Jul 2019 11:27:57 +0200 Subject: [PATCH 1/5] Fix a few PSR-standard issues (not all though) --- src/Artisaninweb/SoapWrapper/Client.php | 363 ++++++------ .../Exceptions/ServiceAlreadyExists.php | 2 +- .../Exceptions/ServiceMethodNotExists.php | 2 +- .../Exceptions/ServiceNotFound.php | 2 +- src/Artisaninweb/SoapWrapper/Facade.php | 14 +- src/Artisaninweb/SoapWrapper/Service.php | 522 +++++++++--------- .../SoapWrapper/ServiceProvider.php | 48 +- src/Artisaninweb/SoapWrapper/SoapWrapper.php | 220 ++++---- 8 files changed, 587 insertions(+), 586 deletions(-) diff --git a/src/Artisaninweb/SoapWrapper/Client.php b/src/Artisaninweb/SoapWrapper/Client.php index aa46e8f..8ffd7be 100644 --- a/src/Artisaninweb/SoapWrapper/Client.php +++ b/src/Artisaninweb/SoapWrapper/Client.php @@ -6,186 +6,187 @@ class Client extends SoapClient { - /** - * @var string - */ - protected $wsdl; - - /** - * Client constructor. - * - * @param string $wsdl - * @param array $options - * @param array $headers - */ - public function __construct($wsdl, $options, array $headers = []) - { - parent::SoapClient($wsdl, $options); - - if (!empty($headers)) { - $this->headers($headers); + /** + * @var string + */ + protected $wsdl; + + /** + * Client constructor. + * + * @param string $wsdl + * @param array $options + * @param array $headers + */ + public function __construct($wsdl, $options, array $headers = []) + { + parent::SoapClient($wsdl, $options); + + if (!empty($headers)) { + $this->headers($headers); + } + } + + /** + * Get all functions from the service + * + * @return mixed + */ + public function getFunctions() + { + return $this->__getFunctions(); + } + + /** + * Get the last request + * + * @return mixed + */ + public function getLastRequest() + { + return $this->__getLastRequest(); + } + + /** + * Get the last response + * + * @return mixed + */ + public function getLastResponse() + { + return $this->__getLastResponse(); + } + + /** + * Get the last request headers + * + * @return mixed + */ + public function getLastRequestHeaders() + { + return $this->__getLastRequestHeaders(); + } + + /** + * Get the last response headers + * + * @return mixed + */ + public function getLastResponseHeaders() + { + return $this->__getLastResponseHeaders(); + } + + /** + * Get the types + * + * @return mixed + */ + public function getTypes() + { + return $this->__getTypes(); + } + + /** + * Get all the set cookies + * + * @return mixed + */ + public function getCookies() + { + return $this->__getCookies(); + } + + /** + * Set a new cookie + * + * @param string $name + * @param string $value + * + * @return $this + */ + public function cookie($name, $value) + { + $this->__setCookie($name, $value); + + return $this; + } + + /** + * Set the location + * + * @param string $location + * + * @return $this + */ + public function location($location = '') + { + $this->__setLocation($location); + + return $this; + } + + /** + * Set the Soap headers + * + * @param array $headers + * + * @return $this + */ + protected function headers(array $headers = []) + { + $this->__setSoapHeaders($headers); + + return $this; + } + + /** + * Do soap request + * + * @param string $request + * @param string $location + * @param string $action + * @param string $version + * @param string $one_way + * + * @return mixed + */ + public function doRequest($request, $location, $action, $version, $one_way) + { + return $this->__doRequest($request, $location, $action, $version, $one_way); + } + + /** + * Do a soap call on the webservice client + * + * @param string $function + * @param array $params + * + * @return mixed + */ + public function call($function, $params) + { + return call_user_func_array([$this, $function], $params); + } + + /** + * Allias to do a soap call on the webservice client + * + * @param string $function + * @param array $params + * @param array $options + * @param null $inputHeader + * @param null $outputHeaders + * + * @return mixed + */ + public function SoapCall( + $function, + array $params, + array $options = null, + $inputHeader = null, + &$outputHeaders = null + ) { + return $this->__soapCall($function, $params, $options, $inputHeader, $outputHeaders); } - } - - /** - * Get all functions from the service - * - * @return mixed - */ - public function getFunctions() - { - return $this->__getFunctions(); - } - - /** - * Get the last request - * - * @return mixed - */ - public function getLastRequest() - { - return $this->__getLastRequest(); - } - - /** - * Get the last response - * - * @return mixed - */ - public function getLastResponse() - { - return $this->__getLastResponse(); - } - - /** - * Get the last request headers - * - * @return mixed - */ - public function getLastRequestHeaders() - { - return $this->__getLastRequestHeaders(); - } - - /** - * Get the last response headers - * - * @return mixed - */ - public function getLastResponseHeaders() - { - return $this->__getLastResponseHeaders(); - } - - /** - * Get the types - * - * @return mixed - */ - public function getTypes() - { - return $this->__getTypes(); - } - - /** - * Get all the set cookies - * - * @return mixed - */ - public function getCookies() - { - return $this->__getCookies(); - } - - /** - * Set a new cookie - * - * @param string $name - * @param string $value - * - * @return $this - */ - public function cookie($name, $value) - { - $this->__setCookie($name, $value); - - return $this; - } - - /** - * Set the location - * - * @param string $location - * - * @return $this - */ - public function location($location = '') - { - $this->__setLocation($location); - - return $this; - } - - /** - * Set the Soap headers - * - * @param array $headers - * - * @return $this - */ - protected function headers(array $headers = []) - { - $this->__setSoapHeaders($headers); - - return $this; - } - - /** - * Do soap request - * - * @param string $request - * @param string $location - * @param string $action - * @param string $version - * @param string $one_way - * - * @return mixed - */ - public function doRequest($request, $location, $action, $version, $one_way) - { - return $this->__doRequest($request, $location, $action, $version, $one_way); - } - - /** - * Do a soap call on the webservice client - * - * @param string $function - * @param array $params - * - * @return mixed - */ - public function call($function, $params) - { - return call_user_func_array([$this, $function], $params); - } - - /** - * Allias to do a soap call on the webservice client - * - * @param string $function - * @param array $params - * @param array $options - * @param null $inputHeader - * @param null $outputHeaders - * - * @return mixed - */ - public function SoapCall($function, - array $params, - array $options = null, - $inputHeader = null, - &$outputHeaders = null - ) { - return $this->__soapCall($function, $params, $options, $inputHeader, $outputHeaders); - } } diff --git a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceAlreadyExists.php b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceAlreadyExists.php index 1fb03f0..166c2c5 100644 --- a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceAlreadyExists.php +++ b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceAlreadyExists.php @@ -6,5 +6,5 @@ class ServiceAlreadyExists extends Exception { - // + // } diff --git a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceMethodNotExists.php b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceMethodNotExists.php index 8ea7556..b31e9b0 100644 --- a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceMethodNotExists.php +++ b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceMethodNotExists.php @@ -6,5 +6,5 @@ class ServiceMethodNotExists extends Exception { - // + // } diff --git a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceNotFound.php b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceNotFound.php index 2e78202..1d51ce3 100644 --- a/src/Artisaninweb/SoapWrapper/Exceptions/ServiceNotFound.php +++ b/src/Artisaninweb/SoapWrapper/Exceptions/ServiceNotFound.php @@ -6,5 +6,5 @@ class ServiceNotFound extends Exception { - // + // } diff --git a/src/Artisaninweb/SoapWrapper/Facade.php b/src/Artisaninweb/SoapWrapper/Facade.php index ac54d1e..4cc9781 100644 --- a/src/Artisaninweb/SoapWrapper/Facade.php +++ b/src/Artisaninweb/SoapWrapper/Facade.php @@ -4,11 +4,11 @@ class Facade extends \Illuminate\Support\Facades\Facade { - /** - * {@inheritDoc} - */ - protected static function getFacadeAccessor() - { - return SoapWrapper::class; - } + /** + * {@inheritDoc} + */ + protected static function getFacadeAccessor() + { + return SoapWrapper::class; + } } diff --git a/src/Artisaninweb/SoapWrapper/Service.php b/src/Artisaninweb/SoapWrapper/Service.php index 33fa959..e984b0f 100644 --- a/src/Artisaninweb/SoapWrapper/Service.php +++ b/src/Artisaninweb/SoapWrapper/Service.php @@ -7,240 +7,240 @@ class Service { - /** - * @var SoapClient - */ - protected $client; - - /** - * @var string - */ - protected $wsdl; - - /** - * @var boolean - */ - protected $trace; - - /** - * @var array - */ - protected $headers; - - /** - * @var string - */ - protected $cache; - - /** - * @var bool - */ - protected $certificate; - - /** - * @var array - */ - protected $options; - - /** - * @var array - */ - protected $classmap; - - /** - * Service constructor. - */ - public function __construct() - { - $this->wsdl = null; - $this->client = null; - $this->certificate = false; - $this->options = []; - $this->classmap = []; - $this->headers = []; - } - - /** - * Set a custom client - * - * @param SoapClient $client - * - * @return $this - */ - public function client(SoapClient $client) - { - $this->client = $client; - - return $this; - } - - /** - * Get the custom client - * - * @return SoapClient - */ - public function getClient() - { - return $this->client; - } - - /** - * Set the wsdl of the service - * - * @param string $wsdl - * - * @return $this - */ - public function wsdl($wsdl) - { - $this->wsdl = $wsdl; - - return $this; - } - - /** - * Get the wsdl from the service - * - * @return string - */ - public function getWsdl() - { - return $this->wsdl; - } - - /** - * Set trace option - enables tracing of request - * - * @param boolean $trace - * - * @return $this - */ - public function trace($trace) - { - $this->trace = $trace; - - return $this; - } - - /** - * Get the trace option - * - * @return boolean - */ - public function getTrace() - { - return $this->trace; - } - - /** - * Set the WSDL cache - * - * @param $cache - * - * @return $this - */ - public function cache($cache) - { - $this->cache = $cache; - - return $this; - } - - /** - * Get the WSDL cache - * - * @return string - */ - public function getCache() - { - return $this->cache; - } - - /** - * @param array $classmap - * - * @return $this - */ - public function classMap(array $classmap) - { - $this->classmap = $classmap; - - return $this; - } - - /** - * Get the classmap - * - * @return array - */ - public function getClassmap() - { - $classmap = $this->classmap; - $classes = [] ; - - if (!empty($classmap)) { - foreach ($classmap as $class) { - // Can't use end because of strict mode :( - $name = current(array_slice(explode('\\', $class), -1, 1, true)); - - $classes[$name] = $class; - } + /** + * @var SoapClient + */ + protected $client; + + /** + * @var string + */ + protected $wsdl; + + /** + * @var boolean + */ + protected $trace; + + /** + * @var array + */ + protected $headers; + + /** + * @var string + */ + protected $cache; + + /** + * @var bool + */ + protected $certificate; + + /** + * @var array + */ + protected $options; + + /** + * @var array + */ + protected $classmap; + + /** + * Service constructor. + */ + public function __construct() + { + $this->wsdl = null; + $this->client = null; + $this->certificate = false; + $this->options = []; + $this->classmap = []; + $this->headers = []; + } + + /** + * Set a custom client + * + * @param SoapClient $client + * + * @return $this + */ + public function client(SoapClient $client) + { + $this->client = $client; + + return $this; + } + + /** + * Get the custom client + * + * @return SoapClient + */ + public function getClient() + { + return $this->client; + } + + /** + * Set the wsdl of the service + * + * @param string $wsdl + * + * @return $this + */ + public function wsdl($wsdl) + { + $this->wsdl = $wsdl; + + return $this; + } + + /** + * Get the wsdl from the service + * + * @return string + */ + public function getWsdl() + { + return $this->wsdl; + } + + /** + * Set trace option - enables tracing of request + * + * @param boolean $trace + * + * @return $this + */ + public function trace($trace) + { + $this->trace = $trace; + + return $this; + } + + /** + * Get the trace option + * + * @return boolean + */ + public function getTrace() + { + return $this->trace; } - return $classes; - } - - /** - * Set the extra options on the SoapClient - * - * @param array $options - * - * @return $this - */ - public function options(array $options) - { - $this->options = $options; - - return $this; - } - - /** - * Get the extra options - * - * @return array - */ - public function getOptions() - { - $options = [ - 'trace' => $this->getTrace(), - 'cache_wsdl' => $this->getCache(), - 'classmap' => $this->getClassmap(), - ]; - - if ($this->certificate) { - $options['local_cert'] = $this->certificate; + /** + * Set the WSDL cache + * + * @param $cache + * + * @return $this + */ + public function cache($cache) + { + $this->cache = $cache; + + return $this; } - $this->options = array_merge($options, $this->options); - - return $this->options; - } - - /** - * Set the certificate location - * - * @param string $certificate - * - * @return $this - */ - public function certificate($certificate) - { - if ($certificate) { - $this->certificate = $certificate; + /** + * Get the WSDL cache + * + * @return string + */ + public function getCache() + { + return $this->cache; + } + + /** + * @param array $classmap + * + * @return $this + */ + public function classMap(array $classmap) + { + $this->classmap = $classmap; + + return $this; } - return $this; - } + /** + * Get the classmap + * + * @return array + */ + public function getClassmap() + { + $classmap = $this->classmap; + $classes = [] ; + + if (!empty($classmap)) { + foreach ($classmap as $class) { + // Can't use end because of strict mode :( + $name = current(array_slice(explode('\\', $class), -1, 1, true)); + + $classes[$name] = $class; + } + } + + return $classes; + } + + /** + * Set the extra options on the SoapClient + * + * @param array $options + * + * @return $this + */ + public function options(array $options) + { + $this->options = $options; + + return $this; + } + + /** + * Get the extra options + * + * @return array + */ + public function getOptions() + { + $options = [ + 'trace' => $this->getTrace(), + 'cache_wsdl' => $this->getCache(), + 'classmap' => $this->getClassmap(), + ]; + + if ($this->certificate) { + $options['local_cert'] = $this->certificate; + } + + $this->options = array_merge($options, $this->options); + + return $this->options; + } + + /** + * Set the certificate location + * + * @param string $certificate + * + * @return $this + */ + public function certificate($certificate) + { + if ($certificate) { + $this->certificate = $certificate; + } + + return $this; + } /** * Get the headers @@ -252,39 +252,39 @@ public function getHeaders() return $this->headers; } - /** - * Create a new SoapHeader - * - * @param string $namespace - * @param string $name - * @param null $data - * @param bool $mustUnderstand - * @param null $actor - * - * @return $this - */ - public function header($namespace, $name, $data = null, $mustUnderstand = false, $actor = null) - { - if ($actor) { - $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand, $actor); - } else { - $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand); + /** + * Create a new SoapHeader + * + * @param string $namespace + * @param string $name + * @param null $data + * @param bool $mustUnderstand + * @param null $actor + * + * @return $this + */ + public function header($namespace, $name, $data = null, $mustUnderstand = false, $actor = null) + { + if ($actor) { + $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand, $actor); + } else { + $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand); + } + + return $this; } - return $this; - } - - /** - * Set the Soap headers - * - * @param SoapHeader $header - * - * @return $this - */ - public function customHeader($header) - { - $this->headers[] = $header; - - return $this; - } + /** + * Set the Soap headers + * + * @param SoapHeader $header + * + * @return $this + */ + public function customHeader($header) + { + $this->headers[] = $header; + + return $this; + } } diff --git a/src/Artisaninweb/SoapWrapper/ServiceProvider.php b/src/Artisaninweb/SoapWrapper/ServiceProvider.php index bbaf49a..991d873 100644 --- a/src/Artisaninweb/SoapWrapper/ServiceProvider.php +++ b/src/Artisaninweb/SoapWrapper/ServiceProvider.php @@ -6,31 +6,31 @@ class ServiceProvider extends LaravelServiceProvider { - /** - * Bootstrap the application events. - * - * @return void - */ - public function boot() - { - // Nothing here - } + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + // Nothing here + } - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $soapWrapper = new SoapWrapper(); + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $soapWrapper = new SoapWrapper(); - if (is_array($this->app['config']['soapwrapper'])) { - $soapWrapper->addByArray($this->app['config']['soapwrapper']); - } + if (is_array($this->app['config']['soapwrapper'])) { + $soapWrapper->addByArray($this->app['config']['soapwrapper']); + } - $this->app->bindIf(SoapWrapper::class, function () use ($soapWrapper) { - return $soapWrapper; - }); - } + $this->app->bindIf(SoapWrapper::class, function () use ($soapWrapper) { + return $soapWrapper; + }); + } } diff --git a/src/Artisaninweb/SoapWrapper/SoapWrapper.php b/src/Artisaninweb/SoapWrapper/SoapWrapper.php index 9c611e1..2306bce 100644 --- a/src/Artisaninweb/SoapWrapper/SoapWrapper.php +++ b/src/Artisaninweb/SoapWrapper/SoapWrapper.php @@ -10,96 +10,96 @@ class SoapWrapper { - /** - * @var array - */ - protected $services; - - /** - * SoapWrapper constructor - */ - public function __construct() - { - $this->services = []; - } - - /** - * Add a new service to the wrapper - * - * @param string $name - * @param Closure $closure - * - * @return $this - * @throws ServiceAlreadyExists - */ - public function add($name, Closure $closure) - { - if (!$this->has($name)) { - $service = new Service(); - - $closure($service); - - $this->services[$name] = $service; - - return $this; + /** + * @var array + */ + protected $services; + + /** + * SoapWrapper constructor + */ + public function __construct() + { + $this->services = []; } - throw new ServiceAlreadyExists("Service '" . $name . "' already exists."); - } - - /** - * Add services by array - * - * @param array $services - * - * @return $this - * - * @throws ServiceAlreadyExists - * @throws ServiceMethodNotExists - */ - public function addByArray(array $services = []) - { - if (!empty($services)) { - foreach ($services as $name => $methods) { + /** + * Add a new service to the wrapper + * + * @param string $name + * @param Closure $closure + * + * @return $this + * @throws ServiceAlreadyExists + */ + public function add($name, Closure $closure) + { if (!$this->has($name)) { - $service = new Service(); + $service = new Service(); - foreach ($methods as $method => $value) { - if (method_exists($service, $method)) { - $service->{$method}($value); - } else { - throw new ServiceMethodNotExists(sprintf( - "Method '%s' does not exists on the %s service.", - $method, - $name - )); - } - } + $closure($service); - $this->services[$name] = $service; + $this->services[$name] = $service; - continue; + return $this; + } + + throw new ServiceAlreadyExists("Service '" . $name . "' already exists."); + } + + /** + * Add services by array + * + * @param array $services + * + * @return $this + * + * @throws ServiceAlreadyExists + * @throws ServiceMethodNotExists + */ + public function addByArray(array $services = []) + { + if (!empty($services)) { + foreach ($services as $name => $methods) { + if (!$this->has($name)) { + $service = new Service(); + + foreach ($methods as $method => $value) { + if (method_exists($service, $method)) { + $service->{$method}($value); + } else { + throw new ServiceMethodNotExists(sprintf( + "Method '%s' does not exists on the %s service.", + $method, + $name + )); + } + } + + $this->services[$name] = $service; + + continue; + } + + throw new ServiceAlreadyExists(sprintf( + "Service '%s' already exists.", + $name + )); + } } - throw new ServiceAlreadyExists(sprintf( - "Service '%s' already exists.", - $name - )); - } + return $this; } - return $this; - } - - /** - * Get the client - * - * @param string $name - * @param Closure $closure - * - * @return mixed - * @throws ServiceNotFound - */ + /** + * Get the client + * + * @param string $name + * @param Closure $closure + * + * @return mixed + * @throws ServiceNotFound + */ public function client($name, Closure $closure = null) { if ($this->has($name)) { @@ -108,7 +108,7 @@ public function client($name, Closure $closure = null) if (is_null($service->getClient())) { $client = new Client($service->getWsdl(), $service->getOptions(), $service->getHeaders()); - + $service->client($client); } else { $client = $service->getClient(); @@ -120,33 +120,33 @@ public function client($name, Closure $closure = null) throw new ServiceNotFound("Service '" . $name . "' not found."); } - /** - * A easy access call method - * - * @param string $call - * @param array $data - * - * @return mixed - */ - public function call($call, $data = [], $options = []) - { - list($name, $function) = explode('.', $call, 2); - - return $this->client($name, function ($client) use ($function, $data, $options) { - /** @var Client $client */ - return $client->SoapCall($function, $data, $options); - }); - } - - /** - * Check if wrapper has service - * - * @param string $name - * - * @return bool - */ - public function has($name) - { - return (array_key_exists($name, $this->services)); - } + /** + * A easy access call method + * + * @param string $call + * @param array $data + * + * @return mixed + */ + public function call($call, $data = [], $options = []) + { + list($name, $function) = explode('.', $call, 2); + + return $this->client($name, function ($client) use ($function, $data, $options) { + /** @var Client $client */ + return $client->soapCall($function, $data, $options); + }); + } + + /** + * Check if wrapper has service + * + * @param string $name + * + * @return bool + */ + public function has($name) + { + return (array_key_exists($name, $this->services)); + } } From b60a168029aa7d0390fb2b14806e006d1b465f15 Mon Sep 17 00:00:00 2001 From: Fernando Kupper Cardoso Date: Thu, 11 Jul 2019 11:28:22 +0200 Subject: [PATCH 2/5] Remove unused dependency --- src/Artisaninweb/SoapWrapper/SoapWrapper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Artisaninweb/SoapWrapper/SoapWrapper.php b/src/Artisaninweb/SoapWrapper/SoapWrapper.php index 2306bce..c9c5c7e 100644 --- a/src/Artisaninweb/SoapWrapper/SoapWrapper.php +++ b/src/Artisaninweb/SoapWrapper/SoapWrapper.php @@ -3,7 +3,6 @@ namespace Artisaninweb\SoapWrapper; use Closure; -use SoapClient; use Artisaninweb\SoapWrapper\Exceptions\ServiceNotFound; use Artisaninweb\SoapWrapper\Exceptions\ServiceAlreadyExists; use Artisaninweb\SoapWrapper\Exceptions\ServiceMethodNotExists; From 3381c1928e2aa3ec04026a37a6e41dd09faac980 Mon Sep 17 00:00:00 2001 From: Fernando Kupper Cardoso Date: Thu, 11 Jul 2019 11:41:37 +0200 Subject: [PATCH 3/5] Quick wins --- src/Artisaninweb/SoapWrapper/SoapWrapper.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Artisaninweb/SoapWrapper/SoapWrapper.php b/src/Artisaninweb/SoapWrapper/SoapWrapper.php index c9c5c7e..d296bae 100644 --- a/src/Artisaninweb/SoapWrapper/SoapWrapper.php +++ b/src/Artisaninweb/SoapWrapper/SoapWrapper.php @@ -64,15 +64,14 @@ public function addByArray(array $services = []) $service = new Service(); foreach ($methods as $method => $value) { - if (method_exists($service, $method)) { - $service->{$method}($value); - } else { + if (!method_exists($service, $method)) { throw new ServiceMethodNotExists(sprintf( "Method '%s' does not exists on the %s service.", $method, $name )); } + $service->{$method}($value); } $this->services[$name] = $service; @@ -105,12 +104,11 @@ public function client($name, Closure $closure = null) /** @var Service $service */ $service = $this->services[$name]; - if (is_null($service->getClient())) { - $client = new Client($service->getWsdl(), $service->getOptions(), $service->getHeaders()); + $client = $service->getClient(); + if (is_null($client)) { + $client = new Client($service->getWsdl(), $service->getOptions(), $service->getHeaders()); $service->client($client); - } else { - $client = $service->getClient(); } return $closure($client); From 685ddf37748773d23bfa322fecd881bf79f3498a Mon Sep 17 00:00:00 2001 From: Fernando Kupper Cardoso Date: Thu, 11 Jul 2019 13:02:03 +0200 Subject: [PATCH 4/5] Include @method annotation to help IDEs --- src/Artisaninweb/SoapWrapper/Facade.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Artisaninweb/SoapWrapper/Facade.php b/src/Artisaninweb/SoapWrapper/Facade.php index 4cc9781..a409fd3 100644 --- a/src/Artisaninweb/SoapWrapper/Facade.php +++ b/src/Artisaninweb/SoapWrapper/Facade.php @@ -2,6 +2,13 @@ namespace Artisaninweb\SoapWrapper; +/** + * @method static SoapWrapper add(string $name, \Closure $closure) Add a new service to the wrapper + * @method static void addByArray(array $services) Add services by array + * @method static mixed client(string $name, \Closure $closure) Get the client + * @method static mixed call(string $call, array $data, array $options) A easy access call method + * @method static bool has(string $name) Check if wrapper has service + */ class Facade extends \Illuminate\Support\Facades\Facade { /** From 3c4ef933c20a1d2fd5825147a27eb3ef068bd75e Mon Sep 17 00:00:00 2001 From: Fernando Kupper Cardoso Date: Thu, 11 Jul 2019 13:02:10 +0200 Subject: [PATCH 5/5] Fix docblock --- src/Artisaninweb/SoapWrapper/SoapWrapper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Artisaninweb/SoapWrapper/SoapWrapper.php b/src/Artisaninweb/SoapWrapper/SoapWrapper.php index d296bae..d489a2d 100644 --- a/src/Artisaninweb/SoapWrapper/SoapWrapper.php +++ b/src/Artisaninweb/SoapWrapper/SoapWrapper.php @@ -121,7 +121,8 @@ public function client($name, Closure $closure = null) * A easy access call method * * @param string $call - * @param array $data + * @param array $data = [] + * @param array $options = [] * * @return mixed */