LoginDetails   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEmail() 0 3 1
A getPassword() 0 3 1
B __construct() 0 12 5
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\User\Models;
4
5
use VSV\GVQ_API\User\ValueObjects\Email;
6
7
class LoginDetails
8
{
9
    /**
10
     * @var Email
11
     */
12
    private $email;
13
14
    /**
15
     * @var string
16
     */
17
    private $password;
18
19
    /**
20
     * @param array $values
21
     */
22
    public function __construct(array $values)
23
    {
24
        if (!isset($values['email']) || !isset($values['password'])) {
25
            throw new \InvalidArgumentException('Both email and password are required.');
26
        }
27
28
        if ($values['email'] === '' || $values['password'] === '') {
29
            throw new \InvalidArgumentException('Email and password can\'t be empty.');
30
        }
31
32
        $this->email = new Email($values['email']);
33
        $this->password = $values['password'];
34
    }
35
36
    /**
37
     * @return Email
38
     */
39
    public function getEmail(): Email
40
    {
41
        return $this->email;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getPassword(): string
48
    {
49
        return $this->password;
50
    }
51
}
52