CredentialFieldsTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 25
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setCredentialFields() 0 6 1
1
<?php
2
3
/**
4
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
5
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
12
 * @link          https://cakephp.org CakePHP(tm) Project
13
 * @since         1.0.0
14
 * @license       https://opensource.org/licenses/mit-license.php MIT License
15
 */
16
17
declare(strict_types=1);
18
19
namespace Phauthentic\Authentication\Authenticator;
20
21
use Phauthentic\Authentication\Identifier\IdentifierInterface;
22
23
/**
24
 * Sets the user credential fields
25
 */
26
trait CredentialFieldsTrait
27
{
28
    /**
29
     * Credential fields
30
     *
31
     * @var array<string, string>
32
     */
33
    protected array $credentialFields = [
34
        IdentifierInterface::CREDENTIAL_USERNAME => 'username',
35
        IdentifierInterface::CREDENTIAL_PASSWORD => 'password'
36
    ];
37
38
    /**
39
     * Set the fields used to to get the credentials from
40
     *
41
     * @param string $username Username field
42
     * @param string $password Password field
43 8
     * @return $this
44
     */
45 8
    public function setCredentialFields(string $username, string $password): self
46 8
    {
47
        $this->credentialFields[IdentifierInterface::CREDENTIAL_USERNAME] = $username;
48 8
        $this->credentialFields[IdentifierInterface::CREDENTIAL_PASSWORD] = $password;
49
50
        return $this;
51
    }
52
}
53