Completed
Push — master ( dfec85...be4840 )
by Peter
02:18
created

Betting::listCurrentOrders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 9.4285
cc 1
eloc 14
nc 1
nop 9

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace PeterColes\Betfair\Api;
4
5
use PeterColes\Betfair\Api\BaseApi;
6
7
class Betting extends BaseApi
8
{
9
    const ENDPOINT = 'https://api.betfair.com/exchange/betting/rest/v1.0/';
10
11
    public function prepare($params)
12
    {
13
        $params = !empty($params) ? $params[ 0 ] : [ ];
14
15
        $lists = [ 'listCompetitions', 'listCountries', 'listEvents', 'listEventTypes', 'listMarketTypes', 'listVenues', 'listMarketCatalogue' ];
16
        if (in_array($this->method, $lists) && empty($params[ 'filter' ])) {
17
            $params['filter'] = new \stdClass;
18
        }
19
20
        if ($this->method == 'listMarketCatalogue' && empty($params[ 'maxResults' ])) {
21
            $params[ 'maxResults' ] = 1000;
22
        }
23
24
        return $params;
25
    }
26
}
27