102 lines
2.5 KiB
PHP
102 lines
2.5 KiB
PHP
<?php
|
|
namespace Mince;
|
|
|
|
use Index\DateTime;
|
|
use Index\Data\IDbResult;
|
|
|
|
class ServerInfo {
|
|
public function __construct(
|
|
private string $id,
|
|
private string $name,
|
|
private string $details,
|
|
private ?string $javaAddress,
|
|
private ?string $javaVersion,
|
|
private ?string $bedrockAddress,
|
|
private ?string $bedrockVersion,
|
|
private int $created,
|
|
private ?int $deleted,
|
|
) {}
|
|
|
|
public static function fromResult(IDbResult $result): self {
|
|
return new ServerInfo(
|
|
id: $result->getString(0),
|
|
name: $result->getString(1),
|
|
details: $result->getString(2),
|
|
javaAddress: $result->getStringOrNull(3),
|
|
javaVersion: $result->getStringOrNull(4),
|
|
bedrockAddress: $result->getStringOrNull(5),
|
|
bedrockVersion: $result->getStringOrNull(6),
|
|
created: $result->getInteger(7),
|
|
deleted: $result->getIntegerOrNull(8),
|
|
);
|
|
}
|
|
|
|
public function getId(): string {
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): string {
|
|
return $this->name;
|
|
}
|
|
|
|
public function hasDetails(): bool {
|
|
return $this->details !== '';
|
|
}
|
|
|
|
public function getDetails(): string {
|
|
return $this->details;
|
|
}
|
|
|
|
public function hasJavaAddress(): bool {
|
|
return $this->javaAddress !== null;
|
|
}
|
|
|
|
public function getJavaAddress(): ?string {
|
|
return $this->javaAddress;
|
|
}
|
|
|
|
public function hasJavaVersion(): bool {
|
|
return $this->javaVersion !== null;
|
|
}
|
|
|
|
public function getJavaVersion(): ?string {
|
|
return $this->javaVersion;
|
|
}
|
|
|
|
public function hasBedrockAddress(): bool {
|
|
return $this->bedrockAddress !== null;
|
|
}
|
|
|
|
public function getBedrockAddress(): ?string {
|
|
return $this->bedrockAddress;
|
|
}
|
|
|
|
public function hasBedrockVersion(): bool {
|
|
return $this->bedrockVersion !== null;
|
|
}
|
|
|
|
public function getBedrockVersion(): ?string {
|
|
return $this->bedrockVersion;
|
|
}
|
|
|
|
public function getCreatedTime(): int {
|
|
return $this->created;
|
|
}
|
|
|
|
public function getCreatedAt(): DateTime {
|
|
return DateTime::fromUnixTimeSeconds($this->created);
|
|
}
|
|
|
|
public function isDeleted(): bool {
|
|
return $this->deleted !== null;
|
|
}
|
|
|
|
public function getDeletedTime(): ?int {
|
|
return $this->deleted;
|
|
}
|
|
|
|
public function getDeletedAt(): ?DateTime {
|
|
return $this->deleted === null ? null : DateTime::fromUnixTimeSeconds($this->deleted);
|
|
}
|
|
}
|