U2fAuthenticationSuccessEvent::getUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the U2F Security bundle.
5
 *
6
 * (c) Michael Barbey <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mbarbey\U2fSecurityBundle\Event\Authentication;
13
14
use Symfony\Component\EventDispatcher\Event;
15
use Mbarbey\U2fSecurityBundle\Model\User\U2fUserInterface;
16
use Mbarbey\U2fSecurityBundle\Model\Key\U2fKeyInterface;
17
18
/**
19
 * U2F authentication success event
20
 *
21
 * An event dispatched when a user successfully authenticate with it U2F security key.
22
 *
23
 * This event contain the user and the key used to authenticate. The counter of the key has already been updated.
24
 *
25
 * @author Michael Barbey <[email protected]>
26
 */
27
class U2fAuthenticationSuccessEvent extends Event
28
{
29
    private $user;
30
    private $key;
31
32
    /**
33
     * Return the name of the event to use when dispatching this event.
34
     *
35
     * @return string
36
     */
37 1
    public static function getName()
38
    {
39 1
        return 'u2f.authentication.success';
40
    }
41
42
    /**
43
     * @param U2fUserInterface $user    The user who successfully authenticated
44
     * @param U2fKeyInterface $key      The security key used during the authentication
45
     */
46 3
    public function __construct(U2fUserInterface $user, U2fKeyInterface $key)
47
    {
48 3
        $this->user = $user;
49 3
        $this->key = $key;
50 3
    }
51
52
    /**
53
     * Return the user who successfully authenticated with it U2F key.
54
     *
55
     * @return U2fUserInterface
56
     */
57 1
    public function getUser()
58
    {
59 1
        return $this->user;
60
    }
61
62
    /**
63
     * Return the key used to authenticate. The counter of the key has already been updated.
64
     *
65
     * @return U2fKeyInterface
66
     */
67 1
    public function getKey()
68
    {
69 1
        return $this->key;
70
    }
71
}
72