Conditions | 2 |
Paths | 2 |
Total Lines | 71 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
13 | public function testRiskLimitEndpoint() |
||
14 | { |
||
15 | echo "\n //// --- //// \n"; |
||
16 | |||
17 | $bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com'); |
||
18 | |||
19 | $response = $bybit->publicEndpoint(TickerInfo::class, (new TickerInfoRequest())->setSymbol('BTCUSDT'))->execute(); |
||
20 | |||
21 | if ($response->getReturnCode() == 0) { |
||
22 | echo "CODE: {$response->getReturnCode()}\n"; |
||
23 | echo "MESSAGE: {$response->getReturnMessage()}\n"; |
||
24 | |||
25 | /** @var ITickerInfoResponseItemInterface $tickerInfo */ |
||
26 | $tickerInfo = $response->getResult()->getTickerInfo(); |
||
|
|||
27 | |||
28 | echo "Symbol: {$tickerInfo->getSymbol()}\n"; |
||
29 | echo "Bid Price: {$tickerInfo->getBidPrice()}\n"; |
||
30 | echo "Ask Price: {$tickerInfo->getAskPrice()}\n"; |
||
31 | echo "Last Price: {$tickerInfo->getLastPrice()}\n"; |
||
32 | echo "Last Tick Direction: {$tickerInfo->getLastTickDirection()}\n"; |
||
33 | echo "Prev Price 24 hours: {$tickerInfo->getPrevPrice24h()}\n"; |
||
34 | echo "Prev Price 24 hours(%): {$tickerInfo->getPrice24hPcnt()}\n"; |
||
35 | echo "High Price 24 hours: {$tickerInfo->getHighPrice24h()}\n"; |
||
36 | echo "Low Price 24 hours: {$tickerInfo->getLowPrice24h()}\n"; |
||
37 | echo "Prev price 1 hour: {$tickerInfo->getPrevPrice1h()}\n"; |
||
38 | echo "Mark Price: {$tickerInfo->getMarkPrice()}\n"; |
||
39 | echo "Index Price: {$tickerInfo->getIndexPrice()}\n"; |
||
40 | echo "Open Interest: {$tickerInfo->getOpenInterests()}\n"; |
||
41 | echo "Open Interest Value: {$tickerInfo->getOpenInterestValue()}\n"; |
||
42 | echo "Turnover 24 hours: {$tickerInfo->getTurnover24h()}\n"; |
||
43 | echo "Volume 24 hours: {$tickerInfo->getVolume24h()}\n"; |
||
44 | echo "Funding Rate: {$tickerInfo->getFundingRate()}\n"; |
||
45 | echo "Next Funding Time: {$tickerInfo->getNextFundingTime()->format("Y-m-d H:i:s")}\n"; |
||
46 | echo "Predicted Delivery Price: {$tickerInfo->getPredictedDeliveryPrice()}\n"; |
||
47 | echo "Basis Rate: {$tickerInfo->getBasisRate()}\n"; |
||
48 | echo "Delivery Fee Rate: {$tickerInfo->getDeliveryFeeRate()}\n"; |
||
49 | echo "Open Interests Value: {$tickerInfo->getOpenInterestValue()}\n"; |
||
50 | |||
51 | /** |
||
52 | * Return code: 0 |
||
53 | * Return message: OK |
||
54 | * Symbol: BTCUSDT |
||
55 | * Bid Price: 59933.6 |
||
56 | * Ask Price: 59935.7 |
||
57 | * Last Price: 59938 |
||
58 | * Last Tick Direction: ZeroMinusTick |
||
59 | * Prev Price 24 hours: 58627.5 |
||
60 | * Prev Price 24 hours(%): 0.022352 |
||
61 | * High Price 24 hours: 63074.5 |
||
62 | * Low Price 24 hours: 58267.4 |
||
63 | * Prev price 1 hour: 59997 |
||
64 | * Mark Price: 59938 |
||
65 | * Index Price: 59957.26 |
||
66 | * Open Interest: 208384.158 |
||
67 | * Open Interest Value: 12490129662.2 |
||
68 | * Turnover 24 hours: 2907929540.5417 |
||
69 | * Volume 24 hours: 48504.964 |
||
70 | * Funding Rate: 8.407E-5 |
||
71 | * Next Funding Time: 2024-07-15 00:00:00 |
||
72 | * Predicted Delivery Price: 0 |
||
73 | * Basis Rate: 0 |
||
74 | * Delivery Fee Rate: 0 |
||
75 | * Open Interests Value: 12490129662.2 |
||
76 | */ |
||
77 | |||
78 | $this->assertTrue(true); |
||
79 | } else { |
||
80 | echo "API ERORR: " . get_class($this) . "\n"; |
||
81 | echo "CODE: {$response->getReturnCode()} \n"; |
||
82 | echo "MESSAGE: {$response->getReturnMessage()} \n"; |
||
83 | echo "EXTENDED:" . implode(";\n", $response->getExtendedInfo()) . "\n"; |
||
84 | } |
||
87 |