Completed
Push — master ( 586b8e...cb0e4b )
by De Cramer
04:39 queued 53s
created

MethodGetScoresDataProvider::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace eXpansion\Framework\GameTrackmania\DataProviders;
4
5
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider;
6
use eXpansion\Framework\Core\DataProviders\MethodScriptDataProviderInterface;
7
use eXpansion\Framework\Core\ScriptMethods\AbstractScriptMethod;
8
use Maniaplanet\DedicatedServer\Connection;
9
10
/**
11
 * Class MethodGetStoresDataProvider
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2017 Smile
15
 * @package eXpansion\Framework\GameManiaplanet\DataProviders
16
 */
17
class MethodGetScoresDataProvider extends AbstractDataProvider implements MethodScriptDataProviderInterface
18
{
19
    /** @var Connection */
20
    protected $connection;
21
22
    /**
23
     * MethodGetStoresDataProvider constructor.
24
     *
25
     * @param Connection $connection
26
     */
27
    public function __construct(Connection $connection)
28
    {
29
        $this->connection = $connection;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     *
35
     * @param string $pluginId
36
     * @param AbstractScriptMethod $pluginService
37
     */
38
    public function registerPlugin($pluginId, $pluginService)
39
    {
40
        parent::registerPlugin($pluginId, $pluginService);
41
42
        $pluginService->setCurrentDataProvider($this);
43
    }
44
45
46
    /**
47
     * Request call to fetch scores.
48
     *
49
     * @return null
50
     */
51
    public function request()
52
    {
53
        $this->connection->triggerModeScriptEvent('TriggerModeScriptEventArray', ['Trackmania.GetScores'], [(string) time()]);
0 ignored issues
show
Documentation introduced by
array((string) time()) is of type array<integer,string,{"0":"string"}>, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
    }
55
56
    /**
57
     * Set scores.
58
     *
59
     * @param array $params
60
     */
61
    public function setScores($params)
62
    {
63
        $this->dispatch('set', [$params]);
64
    }
65
}
66