Completed
Pull Request — master (#17)
by Frederik
02:00
created

ArrayAuthentication::authenticate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 2
crap 6
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
12
     */
13
    private $users;
14
15
    /**
16
     * ArrayAuthentication constructor.
17
     * @param array $users
18
     */
19
    public function __construct(array $users)
20
    {
21
        $this->users = $users;
22
    }
23
24
    /**
25
     * @param string $username
26
     * @param string $password
27
     * @return bool
28
     */
29
    public function authenticate(string $username, string $password): bool
30
    {
31
        return isset($this->users[$username]) && $this->users[$username] === $password;
32
    }
33
}