Completed
Branch module_structure (3116d9)
by Pablo
02:56
created

PrePushFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 5
dl 30
loc 30
rs 10
ccs 12
cts 12
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUndefined() 9 9 1
A fromArray() 9 9 2

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\Service;
4
5
use PhpGitHooks\Module\Configuration\Domain\Enabled;
6
use PhpGitHooks\Module\Configuration\Domain\PrePush;
7
use PhpGitHooks\Module\Configuration\Domain\Undefined;
8
9 View Code Duplication
class PrePushFactory
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...
10
{
11
    /**
12
     * @return PrePush
13
     */
14 1
    public static function setUndefined()
15
    {
16 1
        return new PrePush(
17 1
            new Undefined(true),
18 1
            new Enabled(false),
19 1
            PrePushExecuteFactory::setUndefined(),
20 1
            MessagesFactory::setUndefined()
21
        );
22
    }
23
24
    /**
25
     * @param array $data
26
     *
27
     * @return PrePush
28
     */
29 1
    public static function fromArray(array $data)
30
    {
31 1
        return new PrePush(
32 1
            new Undefined(false),
33 1
            new Enabled($data['enabled']),
34 1
            PrePushExecuteFactory::fromArray($data['process']),
35 1
            isset($data['messages']) ? MessagesFactory::fromArray($data['messages']) : MessagesFactory::setUndefined()
36
        );
37
    }
38
}
39