Implemented Tamer & Cache Drivers (WIP)
This commit is contained in:
parent
26f0f31cc6
commit
d346c4d23d
39 changed files with 2211 additions and 913 deletions
173
src/FederationLib/Objects/Standard/Client.php
Normal file
173
src/FederationLib/Objects/Standard/Client.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace FederationLib\Objects\Standard;
|
||||
|
||||
use FederationLib\Interfaces\SerializableObjectInterface;
|
||||
|
||||
class Client implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uuid;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $enabled;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $permission_role;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $created_timestamp;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $updated_timestamp;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $seen_timestamp;
|
||||
|
||||
/**
|
||||
* Client constructor.
|
||||
*
|
||||
* @param \FederationLib\Objects\Client|null $client
|
||||
*/
|
||||
public function __construct(?\FederationLib\Objects\Client $client=null)
|
||||
{
|
||||
if($client === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->uuid = $client->getUuid();
|
||||
$this->enabled = $client->isEnabled();
|
||||
$this->name = $client->getName();
|
||||
$this->description = $client->getDescription();
|
||||
$this->permission_role = $client->getPermissionRole();
|
||||
$this->created_timestamp = $client->getCreatedTimestamp();
|
||||
$this->updated_timestamp = $client->getUpdatedTimestamp();
|
||||
$this->seen_timestamp = $client->getSeenTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUuid(): string
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissionRole(): int
|
||||
{
|
||||
return $this->permission_role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCreatedTimestamp(): int
|
||||
{
|
||||
return $this->created_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUpdatedTimestamp(): int
|
||||
{
|
||||
return $this->updated_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSeenTimestamp(): int
|
||||
{
|
||||
return $this->seen_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'enabled' => $this->enabled,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'created_timestamp' => $this->created_timestamp,
|
||||
'updated_timestamp' => $this->updated_timestamp,
|
||||
'seen_timestamp' => $this->seen_timestamp
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an object from an array representation
|
||||
*
|
||||
* @param array $array
|
||||
* @return SerializableObjectInterface
|
||||
*/
|
||||
public static function fromArray(array $array): SerializableObjectInterface
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->uuid = $array['uuid'];
|
||||
$object->enabled = $array['enabled'];
|
||||
$object->name = $array['name'];
|
||||
$object->description = $array['description'];
|
||||
$object->created_timestamp = $array['created_timestamp'];
|
||||
$object->updated_timestamp = $array['updated_timestamp'];
|
||||
$object->seen_timestamp = $array['seen_timestamp'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue