PhpUnitGuardCoverageStub   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 4 4 1
A random() 8 8 1
A createEnabled() 8 8 1
A setUndefined() 8 8 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\Message;
7
use PhpGitHooks\Module\Configuration\Domain\PhpUnitGuardCoverage;
8
use PhpGitHooks\Module\Configuration\Domain\Undefined;
9
use PhpGitHooks\Module\Tests\Infrastructure\Stub\RandomStubInterface;
10
11 View Code Duplication
class PhpUnitGuardCoverageStub implements RandomStubInterface
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...
12
{
13
    /**
14
     * @param Undefined $undefined
15
     * @param Enabled   $enabled
16
     * @param Message   $warningMessage
17
     *
18
     * @return PhpUnitGuardCoverage
19
     */
20
    public static function create(Undefined $undefined, Enabled $enabled, Message $warningMessage)
21
    {
22
        return new PhpUnitGuardCoverage($undefined, $enabled, $warningMessage);
23
    }
24
25
    /**
26
     * @return PhpUnitGuardCoverage
27
     */
28
    public static function random()
29
    {
30
        return self::create(
31
            new Undefined(false),
32
            EnabledStub::random(),
33
            MessageStub::random()
34
        );
35
    }
36
37
    /**
38
     * @param string|null $message
39
     * @return PhpUnitGuardCoverage
40
     */
41
    public static function createEnabled($message = null)
42
    {
43
        return self::create(
44
            new Undefined(false),
45
            EnabledStub::create(true),
46
            MessageStub::create($message)
47
        );
48
    }
49
50
    /**
51
     * @return PhpUnitGuardCoverage
52
     */
53
    public static function setUndefined()
54
    {
55
        return self::create(
56
            new Undefined(true),
57
            EnabledStub::create(false),
58
            MessageStub::create(null)
59
        );
60
    }
61
}
62