Completed
Pull Request — master (#307)
by
unknown
03:53
created

UpdateVoteWidgetFactory::createContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Plugins\Gui\Widget;
4
5
use eXpansion\Bundle\VoteManager\Services\VoteService;
6
use eXpansion\Bundle\VoteManager\Structures\Vote;
7
use eXpansion\Framework\Core\Model\Gui\WidgetFactoryContext;
8
use eXpansion\Framework\Core\Model\UserGroups\Group;
9
use eXpansion\Framework\Core\Plugins\Gui\ScriptVariableUpdateFactory;
10
use FML\Script\Builder;
11
12
13
class UpdateVoteWidgetFactory extends ScriptVariableUpdateFactory
14
{
15
16
    /**
17
     * @var Group
18
     */
19
    private $all_players;
20
21
    public function __construct(
22
        $name,
23
        array $variables,
24
        float $maxUpdateFrequency = 0.25,
25
        WidgetFactoryContext $context,
26
        VoteService $voteService,
27
        Group $all_players
28
    ) {
29
        parent::__construct($name, $variables, $maxUpdateFrequency, $context);
30
        $this->all_players = $all_players;
31
    }
32
33
    /** @param Vote $vote */
34
    public function updateVote($vote)
35
    {
36
37
        $out = [
38
            "yes" => $vote->getYes(),
39
            "no" => $vote->getNo(),
40
        ];
41
42
        $this->updateValue($this->all_players, "VoteUpdater", Builder::getArray($out, true));
43
    }
44
45
46
}
47