Completed
Push — master ( 143878...f45699 )
by Taosikai
14:33
created

PasswordAuthentication   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A verify() 0 9 4
1
<?php
2
3
/*
4
 * This file is part of the slince/spike package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Spike\Common\Authentication;
13
14
use Spike\Common\Exception\InvalidArgumentException;
15
16
class PasswordAuthentication implements AuthenticationInterface
17
{
18
    protected $auth;
19
20
    public function __construct($auth)
21
    {
22
        $this->auth = $auth;
23
    }
24
25
    public function verify($auth)
26
    {
27
        if (!isset($auth['username'])) {
28
            throw new InvalidArgumentException('Invalid arguments');
29
        }
30
31
        return ($this->auth['username'] == $auth['username'])
32
            && (!isset($this->auth['password']) || $this->auth['password'] == $auth['password']);
33
    }
34
}