web-base/Core/Objects/ConnectionData.class.php

42 lines
1020 B
PHP
Raw Normal View History

2020-02-09 23:02:19 +01:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Objects;
2020-02-09 23:02:19 +01:00
class ConnectionData {
2020-04-03 15:56:04 +02:00
private string $host;
private int $port;
private string $login;
private string $password;
private array $properties;
2020-02-09 23:02:19 +01:00
2024-04-23 20:14:32 +02:00
public function __construct(string $host, int $port, string $login, string $password) {
2020-02-09 23:02:19 +01:00
$this->host = $host;
$this->port = $port;
$this->login = $login;
$this->password = $password;
2024-04-23 20:14:32 +02:00
$this->properties = [];
2020-02-09 23:02:19 +01:00
}
2022-02-21 13:01:03 +01:00
public function getProperties(): array {
2020-02-09 23:02:19 +01:00
return $this->properties;
}
2020-04-02 01:48:46 +02:00
public function getProperty($key, $defaultValue='') {
return $this->properties[$key] ?? $defaultValue;
2020-02-09 23:02:19 +01:00
}
2022-02-21 13:01:03 +01:00
public function setProperty($key, $val): bool {
if (!is_scalar($val)) {
2020-02-09 23:02:19 +01:00
return false;
}
$this->properties[$key] = $val;
2020-04-03 15:56:04 +02:00
return true;
2020-02-09 23:02:19 +01:00
}
2022-02-21 13:01:03 +01:00
public function getHost(): string { return $this->host; }
public function getPort(): int { return $this->port; }
public function getLogin(): string { return $this->login; }
public function getPassword(): string { return $this->password; }
2020-04-03 15:56:04 +02:00
}