fix minor construct bugs

This commit is contained in:
Dennis Eichhorn 2020-03-05 21:01:09 +01:00
parent 6bcc6c2727
commit 9c9818b87c
3 changed files with 9 additions and 8 deletions

View File

@ -34,5 +34,6 @@ final class NullProfile extends Profile
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -50,10 +50,10 @@ class Profile implements \JsonSerializable
/**
* Birthday.
*
* @var \DateTime
* @var null|\DateTime
* @since 1.0.0
*/
protected \DateTime $birthday;
protected ?\DateTime $birthday = null;
/**
* Account.
@ -90,7 +90,7 @@ class Profile implements \JsonSerializable
{
$this->image = new NullMedia();
$this->birthday = new \DateTime('now');
$this->account = $account ?? new Account();
$this->account = $account ?? new NullAccount();
}
/**
@ -212,13 +212,13 @@ class Profile implements \JsonSerializable
/**
* Set birthday.
*
* @param \DateTime $birthday Birthday
* @param null|\DateTime $birthday Birthday
*
* @return void
*
* @since 1.0.0
*/
public function setBirthday(\DateTime $birthday) : void
public function setBirthday(?\DateTime $birthday) : void
{
$this->birthday = $birthday;
}
@ -226,11 +226,11 @@ class Profile implements \JsonSerializable
/**
* Get birthday.
*
* @return \DateTime
* @return null|\DateTime
*
* @since 1.0.0
*/
public function getBirthday() : \DateTime
public function getBirthday() : ?\DateTime
{
return $this->birthday;
}

View File

@ -83,7 +83,7 @@ echo $this->getData('nav')->render();
<td itemprop="jobTitle">Sailor
<tr>
<th><?= $this->getHtml('Birthday') ?>
<td itemprop="birthDate" itemprop="foundingDate"><?= $profile->getBirthday()->format('Y-m-d'); ?>
<td itemprop="birthDate" itemprop="foundingDate"><?= $profile->getBirthday() !== null ? $profile->getBirthday()->format('Y-m-d') : ''; ?>
<tr>
<th><?= $this->getHtml('Email') ?>
<td itemprop="email"><a href="mailto:>donald.duck@email.com<"><?= $this->printHtml($account->getEmail()); ?></a>