CreateTokenEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 64.71%

Importance

Changes 0
Metric Value
wmc 6
cbo 0
dl 0
loc 79
ccs 11
cts 17
cp 0.6471
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getPurpose() 0 4 1
A getUser() 0 4 1
A getPayload() 0 4 1
A setPayload() 0 4 1
A addPayload() 0 4 1
1
<?php
2
3
namespace Yokai\SecurityTokenBundle\Event;
4
5
use Symfony\Component\EventDispatcher\Event;
6
7
/**
8
 * Event being dispatched before a Token is created.
9
 *
10
 * @author Yann Eugoné <[email protected]>
11
 */
12
class CreateTokenEvent extends Event
13
{
14
    /**
15
     * @var string
16
     */
17
    private $purpose;
18
19
    /**
20
     * @var mixed
21
     */
22
    private $user;
23
24
    /**
25
     * @var array
26
     */
27
    private $payload;
28
29
    /**
30
     * @param string $purpose The token purpose
31
     * @param mixed  $user    The associated user
32
     * @param array  $payload The token payload
33
     */
34 1
    public function __construct($purpose, $user, array $payload)
35
    {
36 1
        $this->purpose = $purpose;
37 1
        $this->user = $user;
38 1
        $this->payload = $payload;
39 1
    }
40
41
    /**
42
     * The token purpose
43
     *
44
     * @return string
45
     */
46 1
    public function getPurpose()
47
    {
48 1
        return $this->purpose;
49
    }
50
51
    /**
52
     * The associated user
53
     *
54
     * @return mixed
55
     */
56 1
    public function getUser()
57
    {
58 1
        return $this->user;
59
    }
60
61
    /**
62
     * The token payload
63
     *
64
     * @return array
65
     */
66 1
    public function getPayload()
67
    {
68 1
        return $this->payload;
69
    }
70
71
    /**
72
     * Replace token payload
73
     *
74
     * @param array $payload The new payload value
75
     */
76
    public function setPayload($payload)
77
    {
78
        $this->payload = $payload;
79
    }
80
81
    /**
82
     * Add payload information to token
83
     *
84
     * @param array $payload Some payload to add
85
     */
86
    public function addPayload($payload)
87
    {
88
        $this->payload = array_merge($this->payload, $payload);
89
    }
90
}
91