Completed
Push — master ( 8db338...3a13f3 )
by Vragov
06:07
created

GroupConfigurationFactory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 42
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
B get() 15 15 5

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
namespace OmnideskBundle\Factory\Group;
3
4
use OmnideskBundle\Configuration\Group\AddGroupRequestConfiguration;
5
use OmnideskBundle\Configuration\Group\EditGroupRequestConfiguration;
6
use OmnideskBundle\Configuration\Group\ListGroupRequestConfiguration;
7
use OmnideskBundle\Configuration\Group\ViewGroupRequestConfiguration;
8
use OmnideskBundle\Exception\BadConfigurationFactoryException;
9
use OmnideskBundle\Factory\AbstractConfigurationFactory;
10
use Symfony\Component\Config\Definition\ConfigurationInterface;
11
12
/**
13
 * Class GroupConfigurationFactory
14
 * @package OmnideskBundle\Factory\Group
15
 */
16 View Code Duplication
class GroupConfigurationFactory extends AbstractConfigurationFactory
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...
17
{
18
    /**
19
     * GroupConfigurationFactory constructor.
20
     * @param AddGroupRequestConfiguration  $addConfiguration
21
     * @param EditGroupRequestConfiguration $editConfiguration
22
     * @param ListGroupRequestConfiguration $listConfiguration
23
     * @param ViewGroupRequestConfiguration $viewConfiguration
24
     */
25
    public function __construct(
26
        AddGroupRequestConfiguration $addConfiguration,
27
        EditGroupRequestConfiguration $editConfiguration,
28
        ListGroupRequestConfiguration $listConfiguration,
29
        ViewGroupRequestConfiguration $viewConfiguration
30
    ) {
31
        $this->addConfiguration = $addConfiguration;
32
        $this->editConfiguration = $editConfiguration;
33
        $this->listConfiguration = $listConfiguration;
34
        $this->viewConfiguration = $viewConfiguration;
35
    }
36
37
    /**
38
     * @param string $type
39
     * @return ConfigurationInterface
40
     * @throws BadConfigurationFactoryException
41
     */
42
    public function get($type)
43
    {
44
        switch ($type) {
45
            case self::CONFIGURATION_ADD:
46
                return $this->addConfiguration;
47
            case self::CONFIGURATION_EDIT:
48
                return $this->editConfiguration;
49
            case self::CONFIGURATION_LIST:
50
                return $this->listConfiguration;
51
            case self::CONFIGURATION_VIEW:
52
                return $this->viewConfiguration;
53
        }
54
55
        throw new BadConfigurationFactoryException();
56
    }
57
}
58