|
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() |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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
|
|
|
|
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.