Skip to content

Commit

Permalink
Ares: support dynamically curol options
Browse files Browse the repository at this point in the history
  • Loading branch information
h4kuna committed Jan 7, 2019
1 parent 7ab2ec2 commit bf8243b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Ares.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function __construct(IFactory $factory = null)
* Load fresh data.
* @throws IdentificationNumberNotFoundException
*/
public function loadData(string $in): Data
public function loadData(string $in, array $options = []): Data
{
try {
$this->loadXML($in, true);
$this->loadXML($in, $options, true);
} catch (IdentificationNumberNotFoundException $e) {
$this->loadXML($in, false);
$this->loadXML($in, $options, false);
}
return $this->getData();
}
Expand All @@ -57,9 +57,9 @@ public function getData(): Data
* Load XML and fill Data object
* @throws IdentificationNumberNotFoundException
*/
private function loadXML(string $in, bool $activeOnly)
private function loadXML(string $in, array $options, bool $activeOnly)
{
$client = $this->factory->createGuzzleClient();
$client = $this->factory->createGuzzleClient($options);
try {
$xmlSource = $client->request('GET', $this->createUrl($in, $activeOnly))->getBody()->getContents();
} catch (\Exception $e) {
Expand Down
4 changes: 2 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public function createData(array $data)
}


public function createGuzzleClient()
public function createGuzzleClient(array $options = [CURLOPT_CONNECTTIMEOUT => 30])
{
return new GuzzleHttp\Client(['curl' => [CURLOPT_CONNECTTIMEOUT => 30]]);
return new GuzzleHttp\Client(['curl' => $options]);
}

}
2 changes: 1 addition & 1 deletion src/IFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function createData(array $data);


/** @return GuzzleHttp\Client */
function createGuzzleClient();
function createGuzzleClient(array $options);


/** @return DataProvider */
Expand Down

0 comments on commit bf8243b

Please sign in to comment.