Skip to content

Commit 47ff195

Browse files
author
mvdrijt
committed
Fixed issue #79
1 parent bd4b077 commit 47ff195

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/Artisaninweb/SoapWrapper/SoapWrapper.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,24 @@ public function addByArray(array $services = [])
100100
* @return mixed
101101
* @throws ServiceNotFound
102102
*/
103-
public function client($name, Closure $closure = null)
104-
{
105-
if ($this->has($name)) {
106-
/** @var Service $service */
107-
$service = $this->services[$name];
108-
$client = $service->getClient();
103+
public function client($name, Closure $closure = null)
104+
{
105+
if ($this->has($name)) {
106+
/** @var Service $service */
107+
$service = $this->services[$name];
108+
109+
if (is_null($service->getClient())) {
110+
$client = new Client($service->getWsdl(), $service->getOptions());
111+
} else {
112+
$client = $service->getClient();
113+
}
109114

110-
if (!$client instanceof SoapClient) {
111-
$client = new Client($service->getWsdl(), $service->getOptions());
112-
}
115+
return $closure($client);
116+
}
113117

114-
return $closure($client);
118+
throw new ServiceNotFound("Service '" . $name . "' not found.");
115119
}
116120

117-
throw new ServiceNotFound("Service '" . $name . "' not found.");
118-
}
119-
120121
/**
121122
* A easy access call method
122123
*

0 commit comments

Comments
 (0)