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

ArrayAuthentication   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 26
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A authenticate() 0 4 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
    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
}