2023-10-20 21:21:17 +00:00
|
|
|
<?php
|
2024-06-03 22:04:36 +00:00
|
|
|
// FileConfigValueInfo.php
|
2023-10-20 21:21:17 +00:00
|
|
|
// Created: 2023-10-20
|
2024-06-03 22:04:36 +00:00
|
|
|
// Updated: 2024-06-03
|
2023-10-20 21:21:17 +00:00
|
|
|
|
|
|
|
namespace Syokuhou;
|
|
|
|
|
2024-06-03 22:04:36 +00:00
|
|
|
class FileConfigValueInfo implements IConfigValueInfo {
|
2023-10-20 21:21:17 +00:00
|
|
|
private string $name;
|
|
|
|
private string $value;
|
|
|
|
|
|
|
|
/** @internal */
|
|
|
|
public function __construct(string $name, string $value = '') {
|
|
|
|
$this->name = $name;
|
|
|
|
$this->value = trim($value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType(): string {
|
|
|
|
// SharpChat config format is just all strings and casts on demand
|
|
|
|
return 'string';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isString(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isInteger(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isFloat(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isBoolean(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isArray(): bool {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getValue(): mixed {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getString(): string {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInteger(): int {
|
|
|
|
return (int)$this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFloat(): float {
|
|
|
|
return (float)$this->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBoolean(): bool {
|
|
|
|
return $this->value !== '0'
|
|
|
|
&& strcasecmp($this->value, 'false') !== 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArray(): array {
|
|
|
|
return explode(' ', $this->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString(): string {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
}
|