AbstractAuth   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getToken() 0 8 2
A setToken() 0 4 1
A getUsername() 0 4 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