mirror of
https://github.com/sitelease/sugar-cube-client.git
synced 2025-10-31 20:12:29 +01:00
Replacing public properties by getters and setters
This commit is contained in:
@ -5,12 +5,20 @@ namespace Gitea\Models;
|
||||
/**
|
||||
* Warps the version of the Gitea server.
|
||||
*/
|
||||
class ServerVersion {
|
||||
class ServerVersion implements \JsonSerializable {
|
||||
|
||||
/**
|
||||
* @var string The version number.
|
||||
*/
|
||||
public $version = '';
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Creates a new server version.
|
||||
* @param string $version The version number.
|
||||
*/
|
||||
function __construct(string $version) {
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new server version from the specified JSON map.
|
||||
@ -18,8 +26,22 @@ class ServerVersion {
|
||||
* @return static The instance corresponding to the specified JSON map.
|
||||
*/
|
||||
static function fromJson(object $map): self {
|
||||
return new static([
|
||||
'version' => isset($map->version) && is_string($map->version) ? $map->version : ''
|
||||
]);
|
||||
return new static(isset($map->version) && is_string($map->version) ? $map->version : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version number.
|
||||
* @return string The version number.
|
||||
*/
|
||||
function getVersion(): string {
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this object to a map in JSON format.
|
||||
* @return \stdClass The map in JSON format corresponding to this object.
|
||||
*/
|
||||
function jsonSerialize(): \stdClass {
|
||||
return (object) ['version' => $this->getVersion()];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user