Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
RegistrationRequest
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEmail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUsername
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPassword
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Auth\Infrastructure\Dto;
4
5use App\Auth\Application\Command\RegistrationCommand;
6use App\Shared\Domain\Exception\ErrorCode;
7use Symfony\Component\ObjectMapper\Attribute\Map;
8use Symfony\Component\Validator\Constraints as Assert;
9
10#[Map(target: RegistrationCommand::class)]
11readonly class RegistrationRequest
12{
13    #[Assert\Email(
14        message: 'The email {{ value }} is not a valid email.',
15        payload: ['code' => ErrorCode::INVALID_EMAIL]
16    )]
17    private readonly string $email;
18
19    #[Assert\Regex(
20        pattern: '/[^a-zA-Z0-9_\-]/',
21        message: "The username can only include alphanumeric characters, underscores, and dashes.",
22        match: false
23    )]
24    private readonly string $username;
25
26    #[Assert\PasswordStrength]
27    private readonly string $password;
28    public function __construct(
29        string $email,
30        string $username,
31        string $password
32    ) {
33        $this->email = $email;
34        $this->username = $username;
35        $this->password = $password;
36    }
37
38    public function getEmail(): string
39    {
40        return $this->email;
41    }
42    public function getUsername(): string
43    {
44        return $this->username;
45    }
46
47    public function getPassword(): string
48    {
49        return $this->password;
50    }
51}