AbstractAuth::getToken()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\Plugin\Auth;
14
15
/**
16
 * @codeCoverageIgnore
17
 */
18
abstract class AbstractAuth implements Adapter
19
{
20
21
    /**
22
     * Holds the authentication realm.
23
     * @var string
24
     */
25
    protected $realm = null;
26
27
    /**
28
     * Holds the base URL.
29
     * @var string
30
     */
31
    protected $base_url = '/';
32
33
    /**
34
     * Holds the auth token.
35
     * @var mixed
36
     */
37
    protected $token;
38
39
    /**
40
     * Holds the user provided username.
41
     * @var string
42
     */
43
    protected $username;
44
45
    /**
46
     * @{@inheritdoc}
47
     */
48
    public function getToken(array $auth_data)
49
    {
50
      if ( is_callable($this->token) ) {
51
        $this->token = call_user_func_array($this->token, array($auth_data));
52
      }
53
54
      return $this->token;
55
    }
56
57
    /**
58
     * Sets the Auth token
59
     *
60
     * @return mixed $token    An auth token, can be a closure or a boolean.
61
     */
62
    public function setToken($token)
63
    {
64
        $this->token = $token;
65
    }
66
67
    /**
68
     * Returns the user provided username.
69
     *
70
     * @return string
71
     */
72
    public function getUsername()
73
    {
74
        return $this->username;
75
    }
76
77
}
78