PhpUnitStub   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 18
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A random() 0 9 1
A createEnabled() 9 9 1
A setUndefined() 9 9 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
namespace PhpGitHooks\Module\Configuration\Tests\Stub;
4
5
use PhpGitHooks\Module\Configuration\Domain\Enabled;
6
use PhpGitHooks\Module\Configuration\Domain\PhpUnit;
7
use PhpGitHooks\Module\Configuration\Domain\PhpUnitOptions;
8
use PhpGitHooks\Module\Configuration\Domain\PhpUnitRandomMode;
9
use PhpGitHooks\Module\Configuration\Domain\Undefined;
10
use PhpGitHooks\Module\Tests\Infrastructure\Stub\RandomStubInterface;
11
12
class PhpUnitStub implements RandomStubInterface
13
{
14
    /**
15
     * @param Undefined         $undefined
16
     * @param Enabled           $enabled
17
     * @param PhpUnitRandomMode $randomMode
18
     * @param PhpUnitOptions    $options
19
     *
20
     * @return PhpUnit
21
     */
22
    public static function create(
23
        Undefined $undefined,
24
        Enabled $enabled,
25
        PhpUnitRandomMode $randomMode,
26
        PhpUnitOptions $options
27
    ) {
28
        return new PhpUnit($undefined, $enabled, $randomMode, $options);
29
    }
30
31
    /**
32
     * @return PhpUnit
33
     */
34
    public static function random()
35
    {
36
        return self::create(
37
            new Undefined(false),
38
            EnabledStub::random(),
39
            PhpUnitRandomModeStub::random(),
40
            PhpUnitOptionsStub::random()
41
        );
42
    }
43
44
    /**
45
     * @param string $options
46
     *
47
     * @return PhpUnit
48
     */
49 View Code Duplication
    public static function createEnabled($options = '--testsuite default')
0 ignored issues
show
Duplication introduced by
This method 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...
50
    {
51
        return self::create(
52
            new Undefined(false),
53
            EnabledStub::create(true),
54
            PhpUnitRandomModeStub::create(true),
55
            PhpUnitOptionsStub::create($options)
56
        );
57
    }
58
59
    /**
60
     * @return PhpUnit
61
     */
62 View Code Duplication
    public static function setUndefined()
0 ignored issues
show
Duplication introduced by
This method 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...
63
    {
64
        return self::create(
65
            new Undefined(true),
66
            EnabledStub::create(false),
67
            PhpUnitRandomModeStub::create(false),
68
            PhpUnitOptionsStub::create(null)
69
        );
70
    }
71
}
72