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

AbstractAdapter::checkInput()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3
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