LoginRequest::getPassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace talismanfr\psbbank\api\vo;
5
6
7
use InvalidArgumentException;
8
9
class LoginRequest
10
{
11
    /** @var string */
12
    private $email;
13
    /** @var string */
14
    private $password;
15
16
    /**
17
     * LoginRequest constructor.
18
     * @param string $email
19
     * @param string $password
20
     */
21 4
    public function __construct(string $email, string $password)
22
    {
23 4
        $this->checkIsValidEmail($email);
24 4
        $this->email = $email;
25 4
        $this->password = $password;
26 4
    }
27
28
    /**
29
     * @return string
30
     */
31 1
    public function getEmail(): string
32
    {
33 1
        return $this->email;
34
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function getPassword(): string
40
    {
41 1
        return $this->password;
42
    }
43
44
    /**
45
     * Check if email is valid
46
     *
47
     * @param string $email
48
     * @throws InvalidArgumentException
49
     */
50 4
    private function checkIsValidEmail(string $email): void
51
    {
52 4
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
53
            throw new InvalidArgumentException('Email ' . $email . ' is not valid');
54
        }
55 4
    }
56
57 4
    public function toArray()
58
    {
59 4
        return get_object_vars($this);
60
    }
61
}