2020-08-17 23:46:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-08-20 18:36:30 +02:00
|
|
|
final class Sharing extends MySqlTable implements JsonSerializable
|
2020-08-17 23:46:58 +02:00
|
|
|
{
|
|
|
|
public const FIELD_USER = 'User';
|
|
|
|
public const FIELD_USER_SHARED = 'UserShared';
|
|
|
|
|
|
|
|
public function __construct($id = null, DatabaseInterface &$database = null)
|
|
|
|
{
|
|
|
|
parent::__construct(self::class, $id, $database);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSharingId(): ?int
|
|
|
|
{
|
|
|
|
if ($this->getPrimaryKey() === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int)$this->getPrimaryKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserId(): int
|
|
|
|
{
|
|
|
|
return $this->getField(self::FIELD_USER);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserShared(): int
|
|
|
|
{
|
|
|
|
return $this->getField(self::FIELD_USER_SHARED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUserId(int $userId): void
|
|
|
|
{
|
|
|
|
$this->setField(self::FIELD_USER, $userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUserShared(int $userShared): void
|
|
|
|
{
|
|
|
|
$this->setField(self::FIELD_USER_SHARED, $userShared);
|
|
|
|
}
|
2020-08-20 18:36:30 +02:00
|
|
|
|
|
|
|
public function jsonSerialize()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'sharingId' => $this->getSharingId(),
|
|
|
|
'userId' => $this->getUserId(),
|
|
|
|
'userSharedId' => $this->getUserShared(),
|
|
|
|
];
|
|
|
|
}
|
2020-08-17 23:46:58 +02:00
|
|
|
}
|