CredentialsDetectorResult::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ArgentCrusade\Stronghold;
4
5
class CredentialsDetectorResult
6
{
7
    const EMAIL = 'email';
8
    const PHONE = 'phone';
9
10
    /**
11
     * @var string
12
     */
13
    public $type;
14
15
    /**
16
     * @var string
17
     */
18
    public $username;
19
20
    /**
21
     * CredentialsDetectorResult constructor.
22
     *
23
     * @param string $type
24
     * @param string $username
25
     */
26
    public function __construct(string $type, string $username)
27
    {
28
        $this->type = $type;
29
        $this->username = $username;
30
    }
31
32
    /**
33
     * Get the credentials with given password.
34
     *
35
     * @param string $password
36
     * @param string $field
37
     *
38
     * @return array
39
     */
40
    public function credentials(string $password, string $field = 'password')
41
    {
42
        return [
43
            $this->type => $this->username,
44
            $field => $password,
45
        ];
46
    }
47
}
48