Completed
Push — master ( 479bd3...ba046f )
by Ross
24:36
created

Index::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
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\Controller\Adminhtml\Adminlogin;
23
24
use Magento\Backend\App\Action\Context;
25
use Magento\Framework\Controller\ResultInterface;
26
use Magento\Framework\View\Result\PageFactory;
27
use Rossmitchell\Twofactor\Model\Config\Admin as UserAdmin;
28
use Rossmitchell\Twofactor\Model\Admin\AdminUser;
29
use Rossmitchell\Twofactor\Model\Urls\Fetcher;
30
use Rossmitchell\Twofactor\Model\Admin\Attribute\IsUsingTwoFactor;
31
32 View Code Duplication
class Index extends AbstractController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
{
34
35
    private $resultPageFactory;
36
37
    /**
38
     * Constructor
39
     *
40
     * @param Context          $context
41
     * @param UserAdmin        $userAdmin
42
     * @param AdminUser        $adminGetter
43
     * @param Fetcher          $fetcher
44
     * @param IsUsingTwoFactor $isUsingTwoFactor
45
     * @param PageFactory      $resultPageFactory
46
     */
47 4
    public function __construct(
48
        Context $context,
49
        UserAdmin $userAdmin,
50
        AdminUser $adminGetter,
51
        Fetcher $fetcher,
52
        IsUsingTwoFactor $isUsingTwoFactor,
53
        PageFactory $resultPageFactory
54
    ) {
55 4
        parent::__construct($context, $userAdmin, $adminGetter, $fetcher, $isUsingTwoFactor);
56 4
        $this->resultPageFactory = $resultPageFactory;
57 4
    }
58
59
    /**
60
     * Execute view action
61
     *
62
     * @return ResultInterface
63
     */
64 4
    public function execute()
65
    {
66 4
        if ($this->shouldActionBeRun() === false) {
67 3
            return $this->getRedirectAction();
68
        }
69 1
        return $this->resultPageFactory->create();
70
    }
71
}
72