Skip to content

Commit

Permalink
path added to heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordy Verschoor authored and DragonBe committed Jul 5, 2024
1 parent 905297a commit 5f5fd55
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
28 changes: 26 additions & 2 deletions src/Vies/HeartBeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class HeartBeat
* @var int The port you want to verify
*/
protected $port;
/**
* @var string The path to append
*/
protected $path;

/**
* @var int The timeout in seconds
Expand All @@ -59,12 +63,13 @@ class HeartBeat
* @param int $port
* @param int $timeout
*/
public function __construct(?string $host = null, int $port = Vies::VIES_PORT, int $timeout = self::DEFAULT_TIMEOUT)
public function __construct(?string $host = null, int $port = Vies::VIES_PORT, ?string $path = null, int $timeout = self::DEFAULT_TIMEOUT)
{
if (null !== $host) {
$this->setHost($host);
}

$this->setPath($path);
$this->setPort($port);
$this->setTimeout($timeout);
}
Expand Down Expand Up @@ -92,6 +97,25 @@ public function setHost(string $host): self
return $this;
}

/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}

/**
* @param string $path
* @return self
*/
public function setPath(string $path): self
{
$this->path = $path;

return $this;
}

/**
* @return int
*/
Expand Down Expand Up @@ -177,7 +201,7 @@ private function readContents($handle): array
throw new \InvalidArgumentException('Expecting a resource to be provided');
}
$response = '';
$uri = sprintf('%s://%s/', Vies::VIES_PROTO, $this->host);
$uri = sprintf('%s://%s%s', Vies::VIES_PROTO, $this->host, $this->path);
$stream = [
'GET ' . $uri . ' HTTP/1.0',
'Host: ' . $this->host,
Expand Down
3 changes: 2 additions & 1 deletion src/Vies/Vies.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Vies
const VIES_PROTO = 'https';
const VIES_DOMAIN = 'ec.europa.eu';
const VIES_PORT = 443;
const VIES_PATH = '/taxation_customs/vies';
const VIES_WSDL = '/taxation_customs/vies/checkVatService.wsdl';
const VIES_TEST_WSDL = '/taxation_customs/vies/checkVatTestService.wsdl';
const VIES_EU_COUNTRY_TOTAL = 28;
Expand Down Expand Up @@ -242,7 +243,7 @@ public function setOptions(array $options): self
*/
public function getHeartBeat(): HeartBeat
{
$this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT);
$this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT, self::VIES_PATH);

return $this->heartBeat;
}
Expand Down

0 comments on commit 5f5fd55

Please sign in to comment.