Passed
Push — master ( d12a36...d0848f )
by Ross
22:44
created

IsUsingTwoFactor::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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\Admin\Attribute;
23
24
use Magento\User\Model\User;
25
26
class IsUsingTwoFactor
27
{
28
29
    const ATTRIBUTE_CODE = 'use_two_factor';
30
31 12
    public function getValue(User $user)
32
    {
33 12
        $value = $user->getData(self::ATTRIBUTE_CODE);
34
35 12
        return ($value == true);
36
    }
37
38 4
    public function setValue(User $user, $value)
39
    {
40 4
        $value = ($value == true);
41 4
        $user->setData(self::ATTRIBUTE_CODE, $value);
42 4
    }
43
}
44