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

PasswordAuthentication::verify()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.2
cc 4
eloc 5
nc 4
nop 1
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
}