-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDestination.php
45 lines (37 loc) · 982 Bytes
/
Destination.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* This file is part of the Ubirak package.
*
* (c) Ubirak team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Ubirak\Component\Healthcheck;
final class Destination
{
private $uri;
/**
* Informs if a destination is reachable
*
* @param string $destination A destination to join for the health check
*
* @throws InvalidDestination when the destination is not supported.
*/
public function __construct(string $uri)
{
$this->uri = filter_var($uri, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
if ($this->uri === false) {
throw InvalidDestination::forUri($uri);
}
}
public function parse(): array
{
return parse_url($this->uri);
}
public function __toString(): string
{
return $this->uri;
}
}