Completed
Pull Request — master (#404)
by De Cramer
03:04
created

NbPlayers::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\ServerInformation\Services\ServerInformation;
4
5
use eXpansion\Bundle\ServerInformation\Ui\Factory\ServerInformationLineFactory;
6
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
7
use eXpansion\Framework\Core\Storage\GameDataStorage;
8
use eXpansion\Framework\Core\Storage\PlayerStorage;
9
use FML\Controls\Control;
10
11
class NbPlayers extends AbstractServerInformation
12
{
13
    /** @var GameDataStorage */
14
    protected $dataStorage;
15
16
    /** @var PlayerStorage */
17
    protected $players;
18
19
    public function __construct(
20
        ServerInformationLineFactory $serverInformationLineFactory,
21
        AdminGroups $adminGroupHelper,
22
        GameDataStorage $dataStorage,
23
        PlayerStorage $players,
24
        $requiredPermission = null
25
    ) {
26
        parent::__construct($serverInformationLineFactory, $adminGroupHelper, $requiredPermission);
27
28
        $this->dataStorage = $dataStorage;
29
        $this->players = $players;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35 View Code Duplication
    public function getInformation(string $login): Control
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...
36
    {
37
        $nbPlayer = count($this->players->getPlayers());
38
        $players = "$nbPlayer / {$this->dataStorage->getServerOptions()->currentMaxPlayers}";
39
40
        return $this->serverInformationLineFactory->create("expansion_server_information.nb_players", $players);
41
    }
42
}
43