Skip to content

Commit

Permalink
Merge pull request #16 from ingrammicro/service-specific-parameters-o…
Browse files Browse the repository at this point in the history
…n-configuration-object

Service specific parameters on configuration object
  • Loading branch information
marcserrat authored Oct 25, 2018
2 parents 46132bc + ced82f4 commit 847ea48
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class Config extends Model
*/
public $sslVerifyHost = true;

/**
* In case that config contains service offset it will be stored here
* @var object
*/
public $service;

/**
* List of runtime services
* @var array
Expand All @@ -84,11 +90,12 @@ public function __construct($source)
if (!is_readable($source)) {
throw new ConfigException("Can't read file $source");
}
$source = json_decode(file_get_contents($source), true);
$source = json_decode(file_get_contents($source));
if (!isset($source)) {
throw new ConfigException("Can't parse JSON config file.");
}
break;
case 'object':
case 'array':
break;
default :
Expand Down Expand Up @@ -131,11 +138,11 @@ public function setApiEndpoint($value)
*/
public function setRuntimeServices($runtimeServices)
{
if (!is_array($runtimeServices)) {
throw new \InvalidArgumentException("The service provider list must be an array, given " . gettype($runtimeServices));
if (!in_array(gettype($runtimeServices), ['array', 'object'])) {
throw new \InvalidArgumentException("The service provider list must be an array or an object, given " . gettype($runtimeServices));
}

$this->runtimeServices = array_merge($this->runtimeServices, $runtimeServices);
$this->runtimeServices = array_merge($this->runtimeServices, (new Model($runtimeServices))->toArray());
}

/**
Expand Down

0 comments on commit 847ea48

Please sign in to comment.