LoginDetails::__construct()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 6
nc 3
nop 1
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