Completed
Push — master ( 5840b0...fcc03f )
by Frederik
04:51
created

ArrayAuthentication::authenticate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

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
eloc 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
12
     */
13
    private $users;
14
15
    /**
16
     * ArrayAuthentication constructor.
17
     * @param array $users
18
     */
19 4
    public function __construct(array $users)
20
    {
21 4
        $this->users = $users;
22 4
    }
23
24
    /**
25
     * @param string $username
26
     * @param string $password
27
     * @return bool
28
     */
29 2
    public function authenticate(string $username, string $password): bool
30
    {
31 2
        return isset($this->users[$username]) && $this->users[$username] === $password;
32
    }
33
}