Skip to content

Commit

Permalink
Add ccFormat as option
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLemaire committed Jul 17, 2022
1 parent 3154a5c commit f5e6df7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Woosmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,24 @@ final class Woosmap extends AbstractHttpProvider implements Provider
*/
private $privateKey;

/**
* @var string|null
*/
private $ccFormat;

/**
* @param HttpClient $client An HTTP adapter
* @param string|null $publicKey Your Public API key (optional)
* @param string|null $privateKey Your Private API Key (optional)
* @param string|null $ccFormat country code format (null|"alpha2"|"alpha3")
*/
public function __construct(HttpClient $client, string $publicKey = null, string $privateKey = null)
public function __construct(HttpClient $client, string $publicKey = null, string $privateKey = null, string $ccFormat = null)
{
parent::__construct($client);

$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
$this->ccFormat = $ccFormat;
}

public function geocodeQuery(GeocodeQuery $query): Collection
Expand Down Expand Up @@ -98,7 +105,7 @@ private function geocodeOrReverseQuery(string $url, Query $query): Collection
$url .= sprintf('&components=%s', urlencode($serializedComponents));
}

if (null !== $ccFormat = $query->getData('cc_format')) {
if (null !== $ccFormat = $query->getData('cc_format', $this->ccFormat)) {
$url .= sprintf('&cc_format=%s', $ccFormat);
}

Expand Down

0 comments on commit f5e6df7

Please sign in to comment.