LoginDetails::getEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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