patternphpMinor
User entity of my domain v2
Viewed 0 times
userdomainentity
Problem
I would appreciate a thorough review of my updated
This is the first time that I'm commenting my code properly according to the phpDocumenter docs. So some feedback on that would also be highly appreciated.
Any other suggestions are always welcome.
User class:
```
namespace Model\Domain\User;
use Model\Domain\Entity\Entity;
use Model\Domain\User\Value\Email;
use Model\Domain\User\Value\Token;
use Model\Domain\User\Value\FullName;
use Model\Domain\User\Value\Password;
use Model\Domain\User\Authentication;
use Model\Domain\User\Value\SeriesNumber;
use Model\Domain\User\Value\RegisterDateTime;
/**
* User entity of the problem domain.
*
* @author John Doe
*/
class User extends Entity
{
/**
* @var FullName $fullName A full name value object.
*/
private $fullName;
/**
* @var Email $email An email value object.
*/
private $email;
/**
* @var Password $password A password value object.
*/
private $password;
/**
* @var RegisterDateTime $registerDateTime A register date and time value object.
*/
private $registerDateTime;
/**
* @var array $authentications A list of Authentication child entities.
*/
private $authentications = [];
/**
* Gets the full name value object.
*
* @return FullName A FullName instance.
*/
public function getFullName()
{
return $this->fullName;
}
/**
* Sets the FullName instance.
*
* @param FullName $fullName A FullName instance.
*
* @return self The current User entity.
*/
public function setFullName(FullName $fullName)
{
$this->fullName = $fullName;
return $this;
}
/**
* Gets the email address.
*
* @return string An email address.
*/
public function getEmail()
User entity class. It's still an anemic domain model, but behavior (like upgradeToPremium(), etc) will be added as I'm developing my application further.This is the first time that I'm commenting my code properly according to the phpDocumenter docs. So some feedback on that would also be highly appreciated.
Any other suggestions are always welcome.
User class:
```
namespace Model\Domain\User;
use Model\Domain\Entity\Entity;
use Model\Domain\User\Value\Email;
use Model\Domain\User\Value\Token;
use Model\Domain\User\Value\FullName;
use Model\Domain\User\Value\Password;
use Model\Domain\User\Authentication;
use Model\Domain\User\Value\SeriesNumber;
use Model\Domain\User\Value\RegisterDateTime;
/**
* User entity of the problem domain.
*
* @author John Doe
*/
class User extends Entity
{
/**
* @var FullName $fullName A full name value object.
*/
private $fullName;
/**
* @var Email $email An email value object.
*/
private $email;
/**
* @var Password $password A password value object.
*/
private $password;
/**
* @var RegisterDateTime $registerDateTime A register date and time value object.
*/
private $registerDateTime;
/**
* @var array $authentications A list of Authentication child entities.
*/
private $authentications = [];
/**
* Gets the full name value object.
*
* @return FullName A FullName instance.
*/
public function getFullName()
{
return $this->fullName;
}
/**
* Sets the FullName instance.
*
* @param FullName $fullName A FullName instance.
*
* @return self The current User entity.
*/
public function setFullName(FullName $fullName)
{
$this->fullName = $fullName;
return $this;
}
/**
* Gets the email address.
*
* @return string An email address.
*/
public function getEmail()
Solution
I think that your code look good, but since you asked specifically about comments, here are my thoughts.
Comments
Comments
- commenting on getters and setters is a controversial topic. Your getter and setter comments generally don't add any new information. They don't really hurt either, but they can have the effect of a reader ignoring them as well as important comments. It can also have the side effect of you overlooking things that should be commented on in depth.
Gets the identifier.andAn identifier.ingetIdentifierare not actually true. It returns a string representation of the identifier, not the identifier itself. The same is true for many of the other getter (but oddly not forgetFullName). This should be expressed in your comments. It should probably also be noted why you are sometimes returning a string and sometimes the identifier object.
string $registerDateTime A date and time of registering.: When I have to pass a string (especially a date time string), I'd like to know how it has to be formated.
Context
StackExchange Code Review Q#63038, answer score: 2
Revisions (0)
No revisions yet.