MethodGetScoresDataProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 50
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A registerPlugin() 0 6 1
A request() 0 4 1
A setScores() 0 4 1
1
<?php
2
3
namespace eXpansion\Framework\GameTrackmania\DataProviders;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
use eXpansion\Framework\Core\ScriptMethods\AbstractScriptMethod;
7
use eXpansion\Framework\Core\DataProviders\MethodScriptDataProviderInterface;
8
use eXpansion\Framework\Core\Services\DedicatedConnection\Factory;
9
use Maniaplanet\DedicatedServer\Connection;
10
11
12
/**
13
 * Class MethodGetStoresDataProvider
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 eXpansion
17
 * @package eXpansion\Framework\GameManiaplanet\DataProviders
18
 */
19
class MethodGetScoresDataProvider extends AbstractDataProvider implements MethodScriptDataProviderInterface
20
{
21
    /** @var Factory */
22
    protected $factory;
23
24
    /**
25
     * MethodGetScoresDataProvider constructor.
26
     *
27
     * @param Factory $factory
28
     */
29
    public function __construct(Factory $factory)
30
    {
31
        $this->factory = $factory;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     *
37
     * @param string $pluginId
38
     * @param AbstractScriptMethod $pluginService
39
     */
40
    public function registerPlugin($pluginId, $pluginService)
41
    {
42
        parent::registerPlugin($pluginId, $pluginService);
43
44
        $pluginService->setCurrentDataProvider($this);
45
    }
46
47
48
    /**
49
     * Request call to fetch scores.
50
     *
51
     * @return void
52
     * @throws
53
     */
54
    public function request()
55
    {
56
        $this->factory->getConnection()->triggerModeScriptEvent("Trackmania.GetScores", ["responseid" => (string) time()]);
57
    }
58
59
    /**
60
     * Set scores.
61
     *
62
     * @param array $params
63
     */
64
    public function setScores($params)
65
    {
66
        $this->dispatch('set', [$params]);
67
    }
68
}
69