Completed
Pull Request — 2.x (#80)
by
unknown
02:00
created

AbstractAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 1 Features 1
Metric Value
wmc 5
c 8
b 1
f 1
lcom 0
cbo 2
dl 0
loc 65
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
login() 0 1 ?
A resume() 0 4 1
A checkInput() 0 10 3
A logout() 0 4 1
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\Auth\Adapter;
10
11
use Aura\Auth\Exception;
12
use Aura\Auth\Status;
13
use Aura\Auth\Auth;
14
15
/**
16
 *
17
 * Authentication adapter
18
 *
19
 * @package Aura.Auth
20
 *
21
 */
22
abstract class AbstractAdapter implements AdapterInterface
23
{
24
    /**
25
     *
26
     * Verifies a set of credentials against a storage backend.
27
     *
28
     * @param array $input Credential input.
29
     *
30
     * @return array An array of login data on success.
31
     *
32
     */
33
    abstract public function login(array $input);
34
35
    /**
36
     *
37
     * Handle logout logic against the storage backend.
38
     *
39
     * @param Auth $auth The authentication obbject to be logged out.
40
     *
41
     * @param string $status The new authentication status after logout.
42
     *
43
     * @return null
44
     *
45
     * @see Status
46
     *
47
     */
48 3
    public function logout(Auth $auth, $status = Status::ANON)
49
    {
50
        // do nothing
51 3
    }
52
53
    /**
54
     *
55
     * Handle a resumed session against the storage backend.
56
     *
57
     * @param Auth $auth The authentication object to be resumed.
58
     *
59
     * @return null
60
     *
61
     */
62 2
    public function resume(Auth $auth)
63
    {
64
        // do nothing
65 2
    }
66
67
    /**
68
     *
69
     * Check the credential input for completeness.
70
     *
71
     * @param array $input
72
     *
73
     * @return bool
74
     *
75
     */
76 18
    protected function checkInput($input)
77
    {
78 18
        if (empty($input['username'])) {
79 2
            throw new Exception\UsernameMissing;
80
        }
81
82 16
        if (empty($input['password'])) {
83 2
            throw new Exception\PasswordMissing;
84
        }
85 14
    }
86
}
87