Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
4 / 7
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
UserChangePasswordDTO
57.14% covered (warning)
57.14%
4 / 7
66.67% covered (warning)
66.67%
2 / 3
3.71
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 fromRequest
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Domain\User\DTOs;
4
5use Domain\Shared\Interfaces\DataTransferObjectInterface;
6use Illuminate\Foundation\Http\FormRequest;
7use Illuminate\Support\Facades\Hash;
8
9readonly final class UserChangePasswordDTO implements DataTransferObjectInterface
10{
11    public string $password;
12
13    public function __construct(array $args)
14    {
15        $this->password = $args['password'];
16    }
17
18    public function toArray(): array
19    {
20        return [
21            'password' => $this->password
22        ];
23    }
24
25    public static function fromRequest(FormRequest $request): UserChangePasswordDTO
26    {
27        return new self([
28            'password' => $request->validated('password'),
29        ]);
30    }
31}