| Conditions | 3 |
| Paths | 2 |
| Total Lines | 112 |
| Code Lines | 45 |
| 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 |
||
| 14 | public function testSuccessEndpoint() |
||
| 15 | { |
||
| 16 | echo "\n //// --- //// \n"; |
||
| 17 | |||
| 18 | $bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ'); |
||
| 19 | |||
| 20 | /** @var IResponseInterface $response */ |
||
| 21 | $response = $bybit->privateEndpoint( |
||
| 22 | GetExecutionList::class, |
||
| 23 | (new GetExecutionListRequest()) |
||
| 24 | ->setSymbol('BTCUSDT') |
||
| 25 | ->setLimit(3) |
||
| 26 | )->execute(); |
||
| 27 | |||
| 28 | if ($response->getReturnCode() == 0) { |
||
| 29 | echo "CODE: {$response->getReturnCode()}\n"; |
||
| 30 | echo "MESSAGE: {$response->getReturnMessage()}\n"; |
||
| 31 | |||
| 32 | /** @var GetExecutionListResponse $execListInfoResponse */ |
||
| 33 | $execListInfoResponse = $response->getResult(); |
||
| 34 | |||
| 35 | echo "Category: {$execListInfoResponse->getCategory()}\n"; |
||
| 36 | echo "Next Page Cursor: {$execListInfoResponse->getNextPageCursor()}\n"; |
||
| 37 | foreach ($execListInfoResponse->getExecutionList() as $exec) { |
||
| 38 | echo "-----\n"; |
||
| 39 | echo "Symbol: {$exec->getSymbol()}\n"; |
||
| 40 | echo "Side: {$exec->getSide()}\n"; |
||
| 41 | echo "Order ID: {$exec->getOrderId()}\n"; |
||
| 42 | echo "Order Link ID: {$exec->getOrderLinkId()}\n"; |
||
| 43 | echo "Order Price: {$exec->getOrderPrice()}\n"; |
||
| 44 | echo "Order Quantity: {$exec->getOrderQty()}\n"; |
||
| 45 | echo "Order Type: {$exec->getOrderType()}\n"; |
||
| 46 | echo "Stop Order Type: {$exec->getOrderType()}\n"; |
||
| 47 | echo "Execution ID: {$exec->getExecId()}\n"; |
||
| 48 | echo "Execution Price: {$exec->getExecPrice()}\n"; |
||
| 49 | echo "Execution Quantity: {$exec->getExecQty()}\n"; |
||
| 50 | echo "Execution Fee: {$exec->getExecFee()}\n"; |
||
| 51 | echo "Execution Type: {$exec->getExecType()}\n"; |
||
| 52 | echo "Execution Value: {$exec->getExecValue()}\n"; |
||
| 53 | echo "Fee Rate: {$exec->getFeeRate()}\n"; |
||
| 54 | echo "Last Liquidity Ind: {$exec->getLastLiquidityInd()}\n"; |
||
| 55 | echo "Is Maker: {$exec->isMaker()}\n"; |
||
| 56 | echo "Leaves Quantity: {$exec->getLeavesQty()}\n"; |
||
| 57 | echo "Closed Size: {$exec->getClosedSize()}\n"; |
||
| 58 | echo "Mark Price: {$exec->getMarkPrice()}\n"; |
||
| 59 | echo "Index Price {$exec->getIndexPrice()}\n"; |
||
| 60 | echo "Underlying Price: {$exec->getUnderlyingPrice()}\n"; |
||
| 61 | echo "Execution Time: {$exec->getExecTime()->format('Y-m-d H:i:s')}\n"; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Return Code: 0 |
||
| 66 | * Return Message: OK |
||
| 67 | * Category: |
||
| 68 | * Next Page Cursor: page_token%3D91113706%26 |
||
| 69 | * ----- |
||
| 70 | * Symbol: BTCUSDT |
||
| 71 | * Side: Sell |
||
| 72 | * Order ID: 6e60910f-2c60-48c6-916e-c9c6946b3bc9 |
||
| 73 | * Order Link ID: |
||
| 74 | * Order Price: 61022 |
||
| 75 | * Order Quantity: 0.015 |
||
| 76 | * Order Type: Market |
||
| 77 | * Stop Order Type: Market |
||
| 78 | * Execution ID: 9cb193fe-4367-5d70-95e6-2831af76586f |
||
| 79 | * Execution Price: 64225.5 |
||
| 80 | * Execution Quantity: 0.015 |
||
| 81 | * Execution Fee: 0.52986038 |
||
| 82 | * Execution Type: Trade |
||
| 83 | * Execution Value: 963.3825 |
||
| 84 | * Fee Rate: 0.00055 |
||
| 85 | * Last Liquidity Ind: RemovedLiquidity |
||
| 86 | * Is Maker: |
||
| 87 | * Leaves Quantity: 0 |
||
| 88 | * Closed Size: 0.015 |
||
| 89 | * Mark Price: 64235.6 |
||
| 90 | * Index Price 0 |
||
| 91 | * Underlying Price: 0 |
||
| 92 | * Execution Time: 2024-06-22 20:52:39 |
||
| 93 | * ----- |
||
| 94 | * Symbol: BTCUSDT |
||
| 95 | * Side: Buy |
||
| 96 | * Order ID: 25d14af5-62ad-472c-a8f5-4573fdb3a3f2 |
||
| 97 | * Order Link ID: |
||
| 98 | * Order Price: 67436.7 |
||
| 99 | * Order Quantity: 0.015 |
||
| 100 | * Order Type: Market |
||
| 101 | * Stop Order Type: Market |
||
| 102 | * Execution ID: 6383ff73-9d54-534c-b8bc-160ba08a8edf |
||
| 103 | * Execution Price: 64233.6 |
||
| 104 | * Execution Quantity: 0.015 |
||
| 105 | * Execution Fee: 0.5299272 |
||
| 106 | * Execution Type: Trade |
||
| 107 | * Execution Value: 963.504 |
||
| 108 | * Fee Rate: 0.00055 |
||
| 109 | * Last Liquidity Ind: RemovedLiquidity |
||
| 110 | * Is Maker: |
||
| 111 | * Leaves Quantity: 0 |
||
| 112 | * Closed Size: 0 |
||
| 113 | * Mark Price: 64235.76 |
||
| 114 | * Index Price 0 |
||
| 115 | */ |
||
| 116 | } else { |
||
| 117 | echo "API ERORR: " . get_class($this) . "\n"; |
||
| 118 | echo "CODE: {$response->getReturnCode()} \n"; |
||
| 119 | echo "MESSAGE: {$response->getReturnMessage()} \n"; |
||
| 120 | echo "EXTENDED:" . implode(";\n", $response->getExtendedInfo()) . "\n"; |
||
| 121 | } |
||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | $this->assertTrue(true); |
||
| 126 | } |
||
| 128 |