This commit is contained in:
Dennis Eichhorn 2020-03-05 20:35:58 +01:00
parent 88362b3254
commit e2fca5d3f8
2 changed files with 21 additions and 8 deletions

View File

@ -24,4 +24,15 @@ namespace Modules\Tag\Models;
*/
final class NullTag extends Tag
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
}

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\Tag\Models;
use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount;
use phpOMS\Contract\ArrayableInterface;
/**
@ -32,7 +34,7 @@ class Tag implements ArrayableInterface, \JsonSerializable
* @var int
* @since 1.0.0
*/
private int $id = 0;
protected int $id = 0;
/**
* Title.
@ -53,10 +55,10 @@ class Tag implements ArrayableInterface, \JsonSerializable
/**
* Creator.
*
* @var null|int|\Modules\Admin\Models\Account
* @var Account
* @since 1.0.0
*/
protected $owner = null;
protected Account $owner;
/**
* Tag type.
@ -69,25 +71,25 @@ class Tag implements ArrayableInterface, \JsonSerializable
/**
* Get created by
*
* @return null|int|\Modules\Admin\Models\Account
* @return Account
*
* @since 1.0.0
*/
public function getOwner()
public function getOwner() : Account
{
return $this->owner;
return $this->owner ?? new NullAccount();
}
/**
* Set created by
*
* @param mixed $id Created by
* @param Account $id Created by
*
* @return void
*
* @since 1.0.0
*/
public function setOwner($id) : void
public function setOwner(Account $id) : void
{
$this->owner = $id;
}