Passed
Push — master ( c51354...8b2af1 )
by Ross
30:39
created

AdminUserLoader::loadAdminUsersRollback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: ross
5
 * Date: 13/05/17
6
 * Time: 23:03
7
 */
8
9
namespace Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits;
10
11
use Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\AdminUser;
12
13
trait AdminUserLoader
14
{
15
    public static function getAdminUserDataPath()
16
    {
17
        return __DIR__.'/../_data/adminUser.php';
18
    }
19
20
    public static function getAdminUserData()
21
    {
22
        $adminData = null;
23
        $dataFile = self::getAdminUserDataPath();
24
        require $dataFile;
0 ignored issues
show
introduced by
"require" statement detected. File manipulations are discouraged. Variables inside are insecure.
Loading history...
25
        if (null === $adminData) {
26
            throw new \Exception("No Admin Data has been set");
0 ignored issues
show
introduced by
Direct throw of Exception is discouraged. Use \Magento\Framework\Exception\LocalizedException instead.
Loading history...
27
        }
28
29
        return $adminData;
30
    }
31
32
    public static function loadAdminUsers()
33
    {
34
        $customerData = self::getAdminUserData();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $customerData is correct as self::getAdminUserData() (which targets Rossmitchell\Twofactor\T...der::getAdminUserData()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
35
        $customerLoader = new AdminUser($customerData);
0 ignored issues
show
introduced by
Direct object instantiation (object of AdminUser) is discouraged in Magento 2.
Loading history...
36
        $customerLoader->loadData();
37
    }
38
}
39