U2fRegistrationFailureEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 43
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getUser() 0 3 1
A __construct() 0 4 1
A getError() 0 3 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\Registration;
13
14
use Symfony\Component\EventDispatcher\Event;
15
use Mbarbey\U2fSecurityBundle\Model\User\U2fUserInterface;
16
17
/**
18
 * U2F registration failure event
19
 *
20
 * An event dispatched when a user fail to register an U2F security key.
21
 *
22
 * This event contain the user and the exception which triggered the failure.
23
 *
24
 * @author Michael Barbey <[email protected]>
25
 */
26
class U2fRegistrationFailureEvent extends Event
27
{
28
    private $user;
29
    private $error;
30
31
    /**
32
     * Return the name of the event to use when dispatching this event.
33
     *
34
     * @return string
35
     */
36 1
    public static function getName()
37
    {
38 1
        return 'u2f.registration.failure';
39
    }
40
41
    /**
42
     * @param U2fUserInterface $user    The user who failed to register a key
43
     * @param \Exception $error         The exception which triggered the failure
44
     */
45 3
    public function __construct(U2fUserInterface $user, \Exception $error)
46
    {
47 3
        $this->user = $user;
48 3
        $this->error = $error;
49 3
    }
50
51
    /**
52
     * Return the user who failed to register a key.
53
     *
54
     * @return U2fUserInterface
55
     */
56 1
    public function getUser()
57
    {
58 1
        return $this->user;
59
    }
60
61
    /**
62
     * Return the exception which triggered the failure
63
     *
64
     * @return \Exception
65
     */
66 1
    public function getError()
67
    {
68 1
        return $this->error;
69
    }
70
}
71