Skip to content

Commit

Permalink
Fixed null handling of options in Connector implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul committed Jun 12, 2016
1 parent abf5c15 commit 34c6a1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Porter/Connector/Http/HttpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public function __construct(HttpOptions $options = null)

public function fetchFreshData($source, EncapsulatedOptions $options = null)
{
if (!$options instanceof HttpOptions) {
if ($options && !$options instanceof HttpOptions) {
throw new \RuntimeException('Options must be an instance of HttpOptions.');
}

return file_get_contents(
$this->getOrCreateUrlBuilder()->buildUrl($source, $options->getQueryParameters()),
$this->getOrCreateUrlBuilder()->buildUrl($source, $options ? $options->getQueryParameters() : []),
false,
stream_context_create([
'http' => array_merge(
$this->options->extractHttpContextOptions(),
$options->extractHttpContextOptions()
$options ? $options->extractHttpContextOptions() : []
),
])
);
Expand Down
4 changes: 2 additions & 2 deletions src/Porter/Connector/Soap/SoapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function __construct($wsdl = null, SoapOptions $options = null)

public function fetchFreshData($source, EncapsulatedOptions $options = null)
{
if (!$options instanceof SoapOptions) {
if ($options && !$options instanceof SoapOptions) {
throw new \RuntimeException('Options must be an instance of SoapOptions.');
}

$params = array_merge($this->options->getParameters(), $options->getParameters());
$params = array_merge($this->options->getParameters(), $options ? $options->getParameters() : []);

return ObjectType::toArray(
\igorw\retry(5, function () use ($source, $params) {
Expand Down

0 comments on commit 34c6a1b

Please sign in to comment.