PrePushStub   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 38.81 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 9 1
A random() 13 13 1
A createAllEnabled() 0 9 1
A setUndefined() 13 13 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\Messages;
7
use PhpGitHooks\Module\Configuration\Domain\PrePush;
8
use PhpGitHooks\Module\Configuration\Domain\Undefined;
9
use PhpGitHooks\Module\Configuration\Model\ExecuteInterface;
10
use PhpGitHooks\Module\Tests\Infrastructure\Stub\RandomStubInterface;
11
12
class PrePushStub implements RandomStubInterface
13
{
14
    /**
15
     * @param Undefined $undefined
16
     * @param Enabled $enabled
17
     * @param ExecuteInterface $execute
18
     * @param Messages $messages
19
     *
20
     * @return PrePush
21
     */
22
    public static function create(Undefined $undefined, Enabled $enabled, ExecuteInterface $execute, Messages $messages)
23
    {
24
        return new PrePush(
25
            $undefined,
26
            $enabled,
27
            $execute,
28
            $messages
29
        );
30
    }
31
32
    /**
33
     * @return PrePush
34
     */
35 View Code Duplication
    public static function random()
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...
36
    {
37
        return self::create(
38
            new Undefined(false),
39
            EnabledStub::random(),
40
            PrePushExecuteStub::create(
41
                PhpUnitStub::random(),
42
                PhpUnitStrictCoverageStub::random(),
43
                PhpUnitGuardCoverageStub::random()
44
            ),
45
            MessagesStub::random()
46
        );
47
    }
48
49
    /**
50
     * @return PrePush
51
     */
52
    public static function createAllEnabled()
53
    {
54
        return self::create(
55
            new Undefined(false),
56
            EnabledStub::create(true),
57
            PrePushExecuteStub::createEnabled(),
58
            MessagesStub::create(MessageStub::create('0k'), MessageStub::create('Faltal'))
59
        );
60
    }
61
62
    /**
63
     * @return PrePush
64
     */
65 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...
66
    {
67
        return self::create(
68
            new Undefined(true),
69
            EnabledStub::create(false),
70
            PrePushExecuteStub::create(
71
                PhpUnitStub::setUndefined(),
72
                PhpUnitStrictCoverageStub::setUndefined(),
73
                PhpUnitGuardCoverageStub::setUndefined()
74
            ),
75
            MessagesStub::random()
76
        );
77
    }
78
}
79