Closed alekseytupichenkov closed 4 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
src/Infrastructure/User/Auth/Auth.php | 2 | 3 | 66.67% | ||
src/Infrastructure/User/ORM/Type/HashedPasswordType.php | 6 | 7 | 85.71% | ||
src/Domain/Shared/ValueObject/AbstractUuid.php | 16 | 18 | 88.89% | ||
src/Infrastructure/Share/ORM/Type/AbstractStringType.php | 6 | 8 | 75.0% | ||
src/Infrastructure/Share/ORM/Type/AbstractUuidType.php | 7 | 12 | 58.33% | ||
<!-- | Total: | 52 | 63 | 82.54% | --> |
Totals | |
---|---|
Change from base Build 263: | -1.4% |
Covered Lines: | 541 |
Relevant Lines: | 574 |
I think this make sense when we've complex VO, but having it for all the VO is a extra work that can easily incur in overengineering. I have to think on it more but I'm quite open.
Yeah, I understand, but it's really strange when I expect some VO in read model but got scalar value
I really avoid hydration in read model as much as possible, mostly for performance reasons
Hm... I see, I think it's depends on task.
So, in case of create read model without hydration, maybe better way to save scalar value every time? I'm about \App\Infrastructure\User\Query\Projections\UserView::deserialize
and \App\Infrastructure\User\Query\Projections\UserView::changeEmail
Something like this
class UserView implements UserViewInterface
{
public static function fromSerializable(Serializable $event): self
{
return self::deserialize($event->serialize());
}
/**
* @throws \Assert\AssertionFailedException
*/
public static function deserialize(array $data): self
{
$instance = new self();
$instance->uuid = $data['uuid'];
$instance->email = $data['email'];
$instance->password = $data['password'];
return $instance;
}
public function serialize(): array
{
return [
'uuid' => $this->getId(),
'email' => $this->email,
];
}
public function uuid(): string
{
return $this->uuid;
}
public function email(): string
{
return $this->email;
}
public function changeEmail(Email $email): void
{
$this->email = $email->toString();
}
public function hashedPassword(): string
{
return $this->password;
}
public function getId(): string
{
return $this->uuid;
}
/** @var string */
private $uuid;
/** @var string */
private $email;
/** @var string */
private $password;
}
@jorge07 Done, also added more tests
Missing test for nullable values in ORM types.
/stale
I'm not sure, but, what do you think about using DBAL types for value objects? In case of using DBAL types, we can guarantee that all entities have or VO or null
PS: It's just proposal, so code can have code-style or other problems :)