Passed
Push — master ( 298035...f88e8a )
by Vince
06:31
created

options::getApiOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 59
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 59
rs 9.7

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php 
2
3
4
class options
5
{
6
    public function getApiOptions()
7
    {
8
        return array(
9
            /**
10
             * Output type
11
             */
12
            'requestType' => 'array', // json, array, object, xml, html, debug
13
14
            /**
15
             * Headers
16
             */
17
            // Max control age header "Access-Control-Max-Age"
18
            'maxWindow' => 86400, // Defaults to 3600 (1 hour)
19
20
            /**
21
             * Add custom headers
22
             * Custom headers must be create in the below format
23
             * nothing will happen if not, no errors no added headers
24
             */
25
            'addHeaders' => array(
26
                ['x-my-new-responsible-api', '1.2'],
27
            ),
28
29
            /**
30
             * JWT refresh options
31
             */
32
            'jwt' => [
33
                'leeway' => 10, // n seconds leeway for expiry
34
                'issuedAt' => time(),
35
                'expires' => time() + 300,
36
                'notBeFor' => 'issuedAt', // issuedAt, or e.g (time()+10)
37
            ],
38
39
            /**
40
             * Rate limiter
41
             */
42
            'rateLimit' => 10, // API call Limit
43
            'rateWindow' => 'MINUTE', // Window timeframe SECOND, MINUTE, HOUR, DAY, [CUSTOM/ A POSITIVE INTEGER]
44
45
            /**
46
             * --- Warning ---
47
             *
48
             * This will override any rate limits
49
             * No maximum calls will be set and the Responsible API
50
             * can run for as many calls and as often as you like
51
             * This should only be used for system admin calls
52
             */
53
            'unlimited' => false, // Unlimited API calls true / false or don't include to default to false
54
55
            /**
56
             * Leaky bucket
57
             *
58
             */
59
            'leak' => true, // Use token bucket "defaults to true"
60
            'leakRate' => 'default', // slow, medium, normal, default, fast or custom positive integer
61
62
            'errors' => 'catchAll',
63
64
            'mock' => 'mock:3$_\7ucJ#D4,Yy=qzwY{&E+Mk_h,7L8:key',
65
        );
66
    }
67
}