Exception
10 months ago
AbstractMonitoringMiddleware.php
10 months ago
ApiCallAttemptMonitoringMiddleware.php
10 months ago
ApiCallMonitoringMiddleware.php
10 months ago
Configuration.php
10 months ago
ConfigurationInterface.php
10 months ago
ConfigurationProvider.php
10 months ago
MonitoringMiddlewareInterface.php
10 months ago
Configuration.php
77 lines
| 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 | * Constructs a new Configuration object with the specified CSM options set. |
| 13 | * |
| 14 | * @param mixed $enabled |
| 15 | * @param string $host |
| 16 | * @param string|int $port |
| 17 | * @param string $clientId |
| 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 | // Unparsable $enabled flag errors on the side of disabling CSM |
| 29 | $this->enabled = filter_var($enabled, FILTER_VALIDATE_BOOLEAN); |
| 30 | $this->clientId = trim($clientId); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * {@inheritdoc} |
| 35 | */ |
| 36 | public function isEnabled() |
| 37 | { |
| 38 | return $this->enabled; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * {@inheritdoc} |
| 43 | */ |
| 44 | public function getClientId() |
| 45 | { |
| 46 | return $this->clientId; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * /{@inheritdoc} |
| 51 | */ |
| 52 | public function getHost() |
| 53 | { |
| 54 | return $this->host; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * {@inheritdoc} |
| 59 | */ |
| 60 | public function getPort() |
| 61 | { |
| 62 | return $this->port; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * {@inheritdoc} |
| 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 | } |