Completed
Push — master ( 70bc12...725ad3 )
by Ross
35:29
created

IsVerified   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 26
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isVerified() 0 11 2
A setIsVerified() 0 4 1
A removeIsVerified() 0 4 1
1
<?php
2
/**
3
 * A two factor authentication module that protects both the admin and customer logins
4
 * Copyright (C) 2017  Ross Mitchell
5
 *
6
 * This file is part of Rossmitchell/Twofactor.
7
 *
8
 * Rossmitchell/Twofactor is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace Rossmitchell\Twofactor\Model\Verification;
23
24
use Rossmitchell\Twofactor\Interfaces\SessionInterface;
25
26
class IsVerified
27
{
28
    const TWO_FACTOR_SESSION_KEY = 'two_factor_verified';
29
30 6
    public function isVerified(SessionInterface $session)
31
    {
32 6
        if ($session->hasData(self::TWO_FACTOR_SESSION_KEY) === false) {
33 4
            return false;
34
        }
35
36 2
        $sessionValue = $session->getData(self::TWO_FACTOR_SESSION_KEY);
37 2
        $isVerified   = ($sessionValue === true);
38
39 2
        return $isVerified;
40
    }
41
42 6
    public function setIsVerified(SessionInterface $session)
43
    {
44 6
        $session->setData(self::TWO_FACTOR_SESSION_KEY, true);
45 6
    }
46
47 2
    public function removeIsVerified(SessionInterface $session)
48
    {
49 2
        $session->unsetData(self::TWO_FACTOR_SESSION_KEY);
50 2
    }
51
}
52