Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| LoginRequestDto | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\User\Application\DTO; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use Yiisoft\Validator\Rule\Length; |
| 12 | use Yiisoft\Validator\Rule\Required; |
| 13 | |
| 14 | /** |
| 15 | * Data Transfer Object for Login Requests. |
| 16 | * |
| 17 | * Encapsulates login credentials and applies Yii3 validation & trimming rules. |
| 18 | * |
| 19 | * @package App\Modules\User\Application\DTO |
| 20 | */ |
| 21 | final class LoginRequestDto |
| 22 | { |
| 23 | #[Required(message: 'Login input cannot be empty')] |
| 24 | #[Length(min: 1, max: 128, lessThanMinMessage: 'Login input cannot be empty')] |
| 25 | public string $login; |
| 26 | |
| 27 | #[Required(message: 'Password input cannot be empty')] |
| 28 | #[Length(min: 1, max: 256, lessThanMinMessage: 'Password input cannot be empty')] |
| 29 | public string $password; |
| 30 | |
| 31 | /** |
| 32 | * LoginRequestDto constructor. |
| 33 | * |
| 34 | * @param string $login Username or email string. |
| 35 | * @param string $username Alias username string. |
| 36 | * @param string $password User password. |
| 37 | */ |
| 38 | public function __construct( |
| 39 | string $login = '', |
| 40 | string $username = '', |
| 41 | string $password = '' |
| 42 | ) { |
| 43 | $this->login = trim($login !== '' ? $login : $username); |
| 44 | $this->password = $password; |
| 45 | } |
| 46 | } |