Conditions | 5 |
Paths | 9 |
Total Lines | 57 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 testInstrumentInfoResponse() |
||
14 | { |
||
15 | echo "\n //// --- //// \n"; |
||
16 | |||
17 | $bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com'); |
||
18 | |||
19 | $response = $bybit->publicEndpoint( |
||
20 | InstrumentInfo::class, |
||
21 | (new InstrumentInfoRequest()) |
||
22 | ->setSymbol('BTCUSDT') |
||
23 | )->execute(); |
||
24 | |||
25 | if ($response->getReturnCode() == 0) { |
||
26 | echo "CODE: {$response->getReturnCode()}\n"; |
||
27 | echo "MESSAGE: {$response->getReturnMessage()}\n"; |
||
28 | |||
29 | /** @var IInstrumentInfoResponseItemInterface $instrumentInfo */ |
||
30 | $instrumentInfo = $response->getResult()->getInstrumentInfoList(); |
||
|
|||
31 | |||
32 | echo "Next Page Cursor: {$instrumentInfo->getNextPageCursor()} \n"; |
||
33 | echo "Symbol: {$instrumentInfo->getSymbol()}\n"; |
||
34 | echo "Contract Type: {$instrumentInfo->getContractType()}\n"; |
||
35 | echo "Status: {$instrumentInfo->getStatus()}\n"; |
||
36 | echo "Base Coin: {$instrumentInfo->getBaseCoin()}\n"; |
||
37 | echo "Settle Coin: {$instrumentInfo->getSettleCoin()} \n"; |
||
38 | echo "Quote Coin: {$instrumentInfo->getQuoteCoin()}\n"; |
||
39 | echo "Launch Time: {$instrumentInfo->getLaunchTime()->format('Y-m-d H:i:s')}\n"; |
||
40 | echo "Delivery Time: {$instrumentInfo->getDeliveryTime()->format('Y-m-d H:i:s')} {}\n"; |
||
41 | echo "Delivery Fee Rate: {$instrumentInfo->getDeliveryFeeRate()} {}\n"; |
||
42 | echo "Price Scale: {$instrumentInfo->getPriceScale()}\n"; |
||
43 | echo "Unified Margin Trade: {$instrumentInfo->getUnifiedMarginTrade()}\n"; |
||
44 | echo "Funding Interval: {$instrumentInfo->getFundingInterval()}\n"; |
||
45 | echo "Leverage Filter: \n"; |
||
46 | foreach ($instrumentInfo->getLeverageFilter()->all() as $filterItem) { |
||
47 | echo " - Minimal Leverage: {$filterItem->getMinLeverage()} \n"; |
||
48 | echo " - Maximal Leverage: {$filterItem->getMaxLeverage()} \n"; |
||
49 | echo " - Leverage Step: {$filterItem->getLeverageStep()} \n"; |
||
50 | } |
||
51 | echo "Price Filter: \n"; |
||
52 | foreach ($instrumentInfo->getPriceFilter()->all() as $priceFilter) { |
||
53 | echo " - Minimal Price: {$priceFilter->getMinPrice()} \n"; |
||
54 | echo " - Maximal Price: {$priceFilter->getMaxPrice()} \n"; |
||
55 | echo " - Tick Size: {$priceFilter->getTickSize()} \n"; |
||
56 | } |
||
57 | echo "Lot Size Filter: \n"; |
||
58 | foreach ($instrumentInfo->getLotSizeFilter()->all() as $lotSizeFilter) { |
||
59 | echo " - Maximal Order Quantity: {$lotSizeFilter->getMaxOrderQty()} \n"; |
||
60 | echo " - Minimal Order Quantity: {$lotSizeFilter->getMinOrderQty()} \n"; |
||
61 | echo " - Quantity Step: {$lotSizeFilter->getQtyStep()} \n"; |
||
62 | } |
||
63 | |||
64 | $this->assertTrue(true); |
||
65 | } else { |
||
66 | echo "API ERORR: " . get_class($this) . "\n"; |
||
67 | echo "CODE: {$response->getReturnCode()} \n"; |
||
68 | echo "MESSAGE: {$response->getReturnMessage()} \n"; |
||
69 | echo "EXTENDED:" . implode(";\n", $response->getExtendedInfo()) . "\n"; |
||
70 | } |
||
73 |