Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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 | ); |
||
67 | } |