Completed
Push — master ( deb1d5...3324ab )
by Pablo
04:13
created

Module/Configuration/Domain/CommitMsg.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Domain;
4
5
use PhpGitHooks\Module\Configuration\Model\ToolInterface;
6
7 View Code Duplication
class CommitMsg implements ToolInterface
0 ignored issues
show
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...
8
{
9
    /**
10
     * @var Enabled
11
     */
12
    private $enabled;
13
    /**
14
     * @var RegularExpression
15
     */
16
    private $regularExpression;
17
    /**
18
     * @var Undefined
19
     */
20
    private $undefined;
21
22
    /**
23
     * CommitMsg constructor.
24
     *
25
     * @param Undefined         $undefined
26
     * @param Enabled           $enabled
27
     * @param RegularExpression $regularExpression
28
     */
29 6
    public function __construct(Undefined $undefined, Enabled $enabled, RegularExpression $regularExpression)
30
    {
31 6
        $this->enabled = $enabled;
32 6
        $this->regularExpression = $regularExpression;
33 6
        $this->undefined = $undefined;
34 6
    }
35
36
    /**
37
     * @return bool
38
     */
39 6
    public function isEnabled()
40
    {
41 6
        return $this->enabled->value();
42
    }
43
44
    /**
45
     * @return RegularExpression
46
     */
47 4
    public function getRegularExpression()
48
    {
49 4
        return $this->regularExpression;
50
    }
51
52
    /**
53
     * @return bool
54
     */
55 5
    public function isUndefined()
56
    {
57 5
        return $this->undefined->value();
58
    }
59
60
    /**
61
     * @param Enabled $enabled
62
     *
63
     * @return CommitMsg
64
     */
65 2
    public function setEnabled(Enabled $enabled)
66
    {
67 2
        return new self(
68 2
            new Undefined(false),
69 2
            $enabled,
70 2
            $this->regularExpression
71 2
        );
72
    }
73
74
    /**
75
     * @param RegularExpression $regularExpression
76
     *
77
     * @return CommitMsg
78
     */
79 1
    public function addRegularExpression(RegularExpression $regularExpression)
80
    {
81 1
        return new self(
82 1
            $this->undefined,
83 1
            $this->enabled,
84
            $regularExpression
85 1
        );
86
    }
87
}
88