ArrayAuthentication::authenticate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Smtp\Authentication;
5
6
use Genkgo\Mail\Protocol\Smtp\AuthenticationInterface;
7
8
final class ArrayAuthentication implements AuthenticationInterface
9
{
10
    /**
11
     * @var array<string, string>
12
     */
13
    private $users;
14
15
    /**
16
     * @param array<string, string> $users
17
     */
18 4
    public function __construct(array $users)
19
    {
20 4
        $this->users = $users;
21 4
    }
22
23
    /**
24
     * @param string $username
25
     * @param string $password
26
     * @return bool
27
     */
28 2
    public function authenticate(string $username, string $password): bool
29
    {
30 2
        return isset($this->users[$username]) && $this->users[$username] === $password;
31
    }
32
}
33