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

PasswordAuthentication::verify()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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