TrackManiaControl/libs/Maniaplanet/DedicatedServer/Structures/ServerOptions.php

59 lines
1.2 KiB
PHP
Raw Normal View History

2014-01-16 16:56:24 +01:00
<?php
/**
* ManiaPlanet dedicated server Xml-RPC client
*
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/
2014-01-20 09:24:17 +01:00
2014-01-16 16:56:24 +01:00
namespace Maniaplanet\DedicatedServer\Structures;
2023-01-17 10:06:56 +01:00
#[\AllowDynamicProperties] // Allow Dynamic Properties for php 8.2 and above
2014-01-16 16:56:24 +01:00
class ServerOptions extends AbstractStructure
{
2014-05-08 19:38:15 +02:00
/** @var string */
2014-01-16 16:56:24 +01:00
public $name;
2014-05-08 19:38:15 +02:00
/** @var string */
2014-01-16 16:56:24 +01:00
public $comment;
2014-05-08 19:38:15 +02:00
/** @var string */
2014-01-16 16:56:24 +01:00
public $password;
2014-05-08 19:38:15 +02:00
/** @var string */
2014-01-16 16:56:24 +01:00
public $passwordForSpectator;
2023-01-17 10:06:56 +01:00
/** @var string */
public $nextCallVoteTimeOut;
2014-05-08 19:38:15 +02:00
/** @var float */
2014-01-16 16:56:24 +01:00
public $callVoteRatio;
2014-05-20 15:20:16 +02:00
/**
* @internal
* @return bool
*/
2024-08-25 22:30:06 +02:00
public function isValid(): bool
2014-05-20 15:20:16 +02:00
{
return is_string($this->name)
&& is_string($this->comment)
&& is_string($this->password)
&& is_string($this->passwordForSpectator)
2014-07-19 21:50:54 +02:00
&& is_int($this->nextCallVoteTimeOut)
&& VoteRatio::isRatio($this->callVoteRatio);
2014-05-20 15:20:16 +02:00
}
/**
* @internal
* @return mixed[]
*/
2024-08-25 22:30:06 +02:00
public function toSetterArray()
2014-05-20 15:20:16 +02:00
{
2024-08-25 22:30:06 +02:00
$out = [];
foreach (get_object_vars($this) as $key => $value) {
if (str_starts_with($key, 'current') || $value === null) {
2014-05-20 15:20:16 +02:00
continue;
2024-08-25 22:30:06 +02:00
}
if ($key === 'nextUseChangingValidationSeed') {
2014-05-20 15:20:16 +02:00
$key = 'useChangingValidationSeed';
2024-08-25 22:30:06 +02:00
}
2014-05-20 15:20:16 +02:00
$out[ucfirst($key)] = $value;
}
return $out;
}
2014-05-08 19:38:15 +02:00
}