RecordHandlerFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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