Completed
Pull Request — master (#75)
by
unknown
02:24
created

MapsWindowFactory::setMaps()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 6
1
<?php
2
3
4
namespace eXpansion\Bundle\Maps\Plugins\Gui;
5
6
use eXpansion\Bundle\Acme\Plugins\Gui\WindowFactory;
7
use eXpansion\Bundle\LocalRecords\Entity\Record;
8
use eXpansion\Framework\Core\Helpers\Time;
9
use eXpansion\Framework\Core\Model\Gui\Grid\DataCollectionFactory;
10
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilder;
11
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilderFactory;
12
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
13
use eXpansion\Framework\Core\Plugins\Gui\GridWindowFactory;
14
use FML\Controls\Frame;
15
use Maniaplanet\DedicatedServer\Structures\Map;
16
17
18
/**
19
 * Class RecordsWindowFactory
20
 *
21
 * @package eXpansion\Bundle\LocalRecords\Plugins\Gui;
22
 * @author  reaby
23
 */
24
class MapsWindowFactory extends GridWindowFactory
25
{
26
27
    /** @var GridBuilderFactory */
28
    protected $gridBuilderFactory;
29
30
    /** @var DataCollectionFactory */
31
    protected $dataCollectionFactory;
32
33
    /** @var Time */
34
    protected $timeFormatter;
35
36
    /**
37
     * @param ManialinkInterface $manialink
38
     * @return void
39
     */
40 View Code Duplication
    protected function createGrid(ManialinkInterface $manialink)
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...
41
    {
42
        $collection = $this->dataCollectionFactory->create($this->getData());
43
        $collection->setPageSize(20);
44
45
        $gridBuilder = $this->gridBuilderFactory->create();
46
        $gridBuilder->setManialink($manialink)
47
            ->setDataCollection($collection)
48
            ->setManialinkFactory($this)
49
            ->addTextColumn(
50
                'index',
51
                'expansion_maps.gui.window.column.index',
52
                '1',
53
                true
54
            )->addTextColumn(
55
                'name',
56
                'expansion_maps.gui.window.column.name',
57
                '3',
58
                true
59
            )->addTextColumn(
60
                'author',
61
                'expansion_maps.gui.window.column.author',
62
                '4'
63
            )->addTextColumn(
64
                'time',
65
                'expansion_maps.gui.window.column.goldtime',
66
                '3',
67
                true
68
            );
69
70
        $manialink->setData('grid', $gridBuilder);
71
    }
72
73
74
    public function setMaps($maps)
75
    {
76
        /**
77
         * @var string $i
78
         * @var Map $map
79
         */
80
        $i = 1;
81
        foreach ($maps as $uid => $map) {
82
            $this->genericData[] = [
83
                'index' => $i++,
84
                'name' => $map->name,
85
                'author' => $map->author,
86
                'time' => $this->timeFormatter->timeToText($map->goldTime, true),
87
            ];
88
        }
89
    }
90
91
}
92