Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

PasswordAuthentication   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A verify() 0 8 4
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Authentication;
7
8
use Spike\Exception\InvalidArgumentException;
9
10
class PasswordAuthentication implements AuthenticationInterface
11
{
12
    protected $auth;
13
14
    public function __construct($auth)
15
    {
16
        $this->auth = $auth;
17
    }
18
19
    public function verify($auth)
20
    {
21
        if (!isset($auth['username'])) {
22
            throw new InvalidArgumentException("Invalid arguments");
23
        }
24
        return ($this->auth['username']  == $auth['username'])
25
            && (!isset($this->auth['password']) || $this->auth['password'] == $auth['password']);
26
    }
27
}