RecordHandlerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 24.07 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 13
loc 54
rs 10
c 0
b 0
f 0
ccs 14
cts 14
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 1
A create() 0 11 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 eXpansion\Bundle\LocalRecords\Services;
4
5
use eXpansion\Bundle\LocalRecords\Model\RecordQueryBuilder;
6
use eXpansion\Framework\Config\Model\ConfigInterface;
7
use eXpansion\Framework\PlayersBundle\Storage\PlayerDb;
8
9
10
/**
11
 * Class RecordHandlerFactory
12
 *
13
 * @package eXpansion\Bundle\LocalRecords\Services;
14
 * @author  oliver de Cramer <[email protected]>
15
 */
16
class RecordHandlerFactory
17
{
18
    /** @var RecordQueryBuilder */
19
    protected $recordQueryBuilder;
20
21
    /** @var PlayerDb */
22
    protected $playerDb;
23
24
    /** @var string */
25
    protected $ordering;
26
27
    /** @var ConfigInterface */
28
    protected $nbRecords;
29
30
    /** @var string */
31
    protected $className;
32
33
    /**
34
     * RecordHandlerFactory constructor.
35
     *
36
     * @param RecordQueryBuilder $recordQueryBuilder
37
     * @param PlayerDb $playerDb
38
     * @param string $ordering
39
     * @param ConfigInterface $nbRecords
40
     * @param string $className
41
     */
42 1 View Code Duplication
    public function __construct(
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...
43
        RecordQueryBuilder $recordQueryBuilder,
44
        PlayerDb $playerDb,
45
        $ordering,
46
        ConfigInterface $nbRecords,
47
        $className = RecordHandler::class
48
    ) {
49 1
        $this->recordQueryBuilder = $recordQueryBuilder;
50 1
        $this->playerDb = $playerDb;
51 1
        $this->ordering = $ordering;
52 1
        $this->nbRecords = $nbRecords;
53 1
        $this->className = $className;
54 1
    }
55
56
57 1
    public function create()
58
    {
59 1
        $class = $this->className;
60
61 1
        return new $class(
62 1
            $this->recordQueryBuilder,
63 1
            $this->playerDb,
64 1
            $this->nbRecords,
65 1
            $this->ordering
66
        );
67
    }
68
69
}
70