U2fRegistrationFailureEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
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\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