federationlib/src/FederationLib/Classes/Configuration/CacheServerConfiguration.php
2023-06-04 14:23:51 -04:00

162 lines
No EOL
3.5 KiB
PHP

<?php
namespace FederationLib\Classes\Configuration;
class CacheServerConfiguration
{
/**
* @var string
*/
private string $name;
/**
* @var bool
*/
private bool $enabled;
/**
* @var string|null
*/
private ?string $host;
/**
* @var int|null
*/
private ?int $port;
/**
* @var string|null
*/
private ?string $driver;
/**
* @var int|null
*/
private ?int $priority;
/**
* @var string|null
*/
private ?string $username;
/**
* @var string|null
*/
private ?string $password;
/**
* @var string|null
*/
private ?string $database;
/**
* @var int|null
*/
private ?int $reconnect_interval;
/**
* CacheServerConfiguration constructor.
*
* @param array $configuration
*/
public function __construct(string $name, array $configuration)
{
$this->name = $configuration['name'] ?? $name;
$this->enabled = $configuration['enabled'] ?? false;
$this->host = $configuration['host'] ?? null;
$this->port = $configuration['port'] ?? null;
$this->driver = $configuration['driver'] ?? null;
$this->priority = $configuration['priority'] ?? null;
$this->username = $configuration['username'] ?? null;
$this->password = $configuration['password'] ?? null;
$this->database = $configuration['database'] ?? null;
$this->reconnect_interval = $configuration['reconnect_interval'] ?? null;
}
/**
* Returns the name of the cache server
*
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* Returns whether the cache server is enabled
*
* @return bool
*/
public function getEnabled(): bool
{
return $this->enabled ?? false;
}
/**
* Returns the host of the cache server
*
* @return string|null
*/
public function getHost(): ?string
{
return $this->host;
}
/**
* @return int|null
*/
public function getPort(): ?int
{
return $this->port;
}
/**
* @return string|null
*/
public function getDriver(): ?string
{
return $this->driver;
}
/**
* @return int|null
*/
public function getPriority(): ?int
{
return $this->priority;
}
/**
* @return string|null
*/
public function getUsername(): ?string
{
return $this->username;
}
/**
* @return string|null
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* @return string|null
*/
public function getDatabase(): ?string
{
return $this->database;
}
/**
* @return int|null
*/
public function getReconnectInterval(): ?int
{
return $this->reconnect_interval;
}
}