| 1 |
<?php |
| 2 |
namespace Aws\ClientSideMonitoring; |
| 3 |
|
| 4 |
class Configuration implements ConfigurationInterface |
| 5 |
{ |
| 6 |
private $clientId; |
| 7 |
private $enabled; |
| 8 |
private $host; |
| 9 |
private $port; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public function __construct($enabled, $host, $port, $clientId = '') |
| 20 |
{ |
| 21 |
$this->host = $host; |
| 22 |
$this->port = filter_var($port, FILTER_VALIDATE_INT); |
| 23 |
if ($this->port === false) { |
| 24 |
throw new \InvalidArgumentException( |
| 25 |
"CSM 'port' value must be an integer!"); |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
$this->enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
| 30 |
$this->clientId = trim($clientId); |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public function isEnabled() |
| 37 |
{ |
| 38 |
return $this->enabled; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public function getClientId() |
| 45 |
{ |
| 46 |
return $this->clientId; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public function getHost() |
| 53 |
{ |
| 54 |
return $this->host; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public function getPort() |
| 61 |
{ |
| 62 |
return $this->port; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public function toArray() |
| 69 |
{ |
| 70 |
return [ |
| 71 |
'client_id' => $this->getClientId(), |
| 72 |
'enabled' => $this->isEnabled(), |
| 73 |
'host' => $this->getHost(), |
| 74 |
'port' => $this->getPort() |
| 75 |
]; |
| 76 |
} |
| 77 |
} |