Completed
Push — master ( 21c1bf...8efbb2 )
by Ross
07:30
created

CustomerLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 0
dl 26
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCustomerData() 9 9 2
A loadCustomer() 6 6 1
A loadCustomerRollback() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: ross
5
 * Date: 22/04/17
6
 * Time: 14:03
7
 */
8
9
namespace Rossmitchell\Twofactor\Tests\Integration\FixtureLoader\Traits;
10
11
12 View Code Duplication
trait CustomerLoader
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...
13
{
14
    public static function getCustomerData()
15
    {
16
        require __DIR__ . '/../_data/customer.php';
0 ignored issues
show
introduced by
"require" statement detected. File manipulations are discouraged. Concatenating is forbidden.
Loading history...
17
        if(!isset($customerData)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
Bug introduced by
The variable $customerData seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
18
            throw new \Exception("No Customer Data has been set");
0 ignored issues
show
introduced by
Direct throw of Exception is discouraged. Use \Magento\Framework\Exception\LocalizedException instead.
Loading history...
19
        }
20
21
        return $customerData;
22
    }
23
24
    static function loadCustomer()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26
        $action = 'load';
27
        $customerData = self::getCustomerData();
28
        require __DIR__ . '/../_loaders/customer.php';
0 ignored issues
show
introduced by
"require" statement detected. File manipulations are discouraged. Concatenating is forbidden.
Loading history...
29
    }
30
31
    static function loadCustomerRollback()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
    {
33
        $action = 'rollback';
34
        $customerData = self::getCustomerData();
35
        require __DIR__ . '/../_loaders/customer.php';
0 ignored issues
show
introduced by
"require" statement detected. File manipulations are discouraged. Concatenating is forbidden.
Loading history...
36
    }
37
}
38