public function __construct(Account $account) { $this->id = $account->getId(); $this->creationDate = $account->getCreationDate(); switch ($account->getStatus()) { case AccountInterface::STATUS_ACTIVE: $this->status = 'active'; break; case AccountInterface::STATUS_INACTIVE: $this->status = 'inactive'; break; case AccountInterface::STATUS_INVITED: $this->status = 'invited'; break; default: throw new RuntimeException('The account status could not be converted to a string.'); } $contact = $account->getContact(); if ($contact instanceof Person) { $this->contact = new PersonEntity($contact); } else { $this->contact = new CompanyEntity($contact); } }