Completed
Pull Request — master (#307)
by
unknown
04:00
created

DediRecs   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A execute() 0 12 2
1
<?php
2
3
4
namespace eXpansion\Bundle\Dedimania\ChatCommands;
5
6
use eXpansion\Bundle\Dedimania\Plugins\Gui\DedirecsWindow;
7
use eXpansion\Bundle\Dedimania\Services\DedimaniaService;
8
use eXpansion\Framework\Core\Model\ChatCommand\AbstractChatCommand;
9
use eXpansion\Framework\Notifications\Services\Notifications;
10
use Symfony\Component\Console\Input\InputInterface;
11
12
13
/**
14
 * Class Records
15
 *
16
 * @package eXpansion\Bundle\LocalRecords\ChatCommand;
17
 * @author  reaby
18
 */
19
class DediRecs extends AbstractChatCommand
20
{
21
    /**
22
     * @var DedirecsWindow
23
     */
24
    private $dedirecsWindow;
25
    /**
26
     * @var DedimaniaService
27
     */
28
    private $dedimaniaService;
29
    /**
30
     * @var Notifications
31
     */
32
    private $notifications;
33
34
    /**
35
     * MapsList constructor.
36
     *
37
     * @param                      $command
38
     * @param array                $aliases
39
     * @param DedirecsWindow       $dedirecsWindow
40
     * @param DedimaniaService     $dedimaniaService
41
     * @param Notifications        $notifications
42
     */
43
    public function __construct(
44
        $command,
45
        array $aliases = [],
46
        DedirecsWindow $dedirecsWindow,
47
        DedimaniaService $dedimaniaService,
48
        Notifications $notifications
49
    ) {
50
        parent::__construct($command, $aliases);
51
52
        $this->dedirecsWindow = $dedirecsWindow;
53
        $this->dedimaniaService = $dedimaniaService;
54
        $this->notifications = $notifications;
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public function execute($login, InputInterface $input)
61
    {
62
        $recs = $this->dedimaniaService->getDedimaniaRecords();
63
64
        if (empty($recs)) {
65
            $this->notifications->error("No dedimania records for this map", [], "Error", 5500, $login);
66
            return;
67
        }
68
69
        $this->dedirecsWindow->setRecords($recs);
70
        $this->dedirecsWindow->create($login);
71
    }
72
}
73