Completed
Push — master ( fe49f7...53f56c )
by Peter
02:15
created

src/Api/Betting.php (6 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PeterColes\Betfair\Api;
4
5
use PeterColes\Betfair\Api\BaseApi;
6
7
class Betting extends BaseApi
8
{
9
    /**
10
     * Betfair API endpoint for betting subsystem requests
11
     */
12
    const ENDPOINT = 'https://api.betfair.com/exchange/betting/rest/v1.0/';
13
14
    /**
15
     * Prepare parameters for API requests, ensuring the mandatory requirments are satisfied
16
     *
17
     * @param array $params
18
     */
19
    public function prepare($params)
20
    {
21
        $this->params = !empty($params) ? $params[ 0 ] : [ ];
22
23
        // force mandatory fields
24
        $this->filter();
25
        $this->maxRecords();
26
    }
27
28
    /**
29
     * Ensure that a filter parameter is passed where mandatory
30
     */
31
    protected filter()
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION
Loading history...
32
    {
33
        $lists = [
0 ignored issues
show
The visibility should be declared for property $lists.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
34
            'listCompetitions',
35
            'listCountries',
36
            'listEvents',
37
            'listEventTypes',
38
            'listMarketTypes',
39
            'listVenues',
40
            'listMarketCatalogue'
41
        ];
42
43
        if (in_array($this->method, $lists) && empty($this->params[ 'filter' ])) {
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
The visibility should be declared for property $this.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
44
            $this->params['filter'] = new \stdClass;
45
        }
46
    }
47
48
    /**
49
     * Ensure that a maxRecord parameter is passed where mandatory
50
     */
51
    protected maxRecords()
52
    {
53
        if ($this->method == 'listMarketCatalogue' && empty($this->params[ 'maxResults' ])) {
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
The visibility should be declared for property $this.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
54
            $this->params[ 'maxResults' ] = 1000;
55
        }
56
    }
57
}
58