oms-Tasks/Models/GroupRelation.php

84 lines
1.5 KiB
PHP
Executable File

<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Tasks\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Tasks\Models;
use Modules\Admin\Models\Group;
use Modules\Admin\Models\NullGroup;
/**
* Task relation to group
*
* @package Modules\Tasks\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class GroupRelation extends RelationAbstract
{
/**
* Relation object
*
* @var Group
* @since 1.0.0
*/
private Group $relation;
/**
* Constructor.
*
* @param null|Group $group Group
* @param int $duty Duty type
*
* @since 1.0.0
*/
public function __construct(Group $group = null, int $duty = DutyType::TO)
{
$this->relation = $group ?? new NullGroup();
$this->duty = $duty;
}
/**
* Get relation object.
*
* @return Group
*
* @since 1.0.0
*/
public function getRelation() : Group
{
return $this->relation;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'duty' => $this->duty,
'relation' => $this->relation,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}