Test Failed
Pull Request — master (#476)
by
unknown
03:13
created

SignupService::signup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\User;
6
7
final class SignupService
8
{
9
    private UserLogin $login;
10
    private UserPassword $password;
11
12
    public function __construct(private UserRepository $userRepository)
13
    {
14
    }
15
16
    public function signup(): User
17
    {
18
        $user = new User($this->login, $this->password);
19
        $this->userRepository->save($user);
20
        return $user;
21
    }
22
23
    public function setLogin(string|UserLogin $login): SignupService
24
    {
25
        if (is_string($login)) {
26
            $this->login = UserLogin::createNew($login, $this->userRepository);
27
        }else {
28
            $this->login = $login;
29
        }
30
31
        return $this;
32
    }
33
34
    public function setPassword(string|UserPassword $password): SignupService
35
    {
36
        if (is_string($password)) {
37
            $this->password = UserPassword::createNew($password,);
38
        }else {
39
            $this->password = $password;
40
        }
41
42
        return $this;
43
    }
44
}
45