Conditions | 2 |
Paths | 2 |
Total Lines | 56 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 | $bybitApi = (new BybitAPI()) |
||
17 | ->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ'); |
||
18 | |||
19 | /** @var IResponseInterface $endpointResponse */ |
||
20 | $endpointResponse = $bybitApi->privateEndpoint(GetOrderList::class, |
||
21 | (new GetOrderListRequest())->setSymbol('BTCUSDT')->setLimit(2)) |
||
22 | ->execute(); |
||
23 | |||
24 | echo "Return code: {$endpointResponse->getReturnCode()} \n"; |
||
25 | echo "Return message: {$endpointResponse->getReturnMessage()} \n"; |
||
26 | |||
27 | /** @var GetOrderListResponse $getOrderListResponse */ |
||
28 | $getOrderListResponse = $endpointResponse->getResult(); |
||
29 | echo "Product Category: {$getOrderListResponse->getCategory()}\n"; |
||
30 | echo "Next Page Cursor: {$getOrderListResponse->getNextPageCursor()}\n"; |
||
31 | echo "Order List:\n"; |
||
32 | |||
33 | /** @var IGetOrderListResponseItemInterface $order */ |
||
34 | foreach ($getOrderListResponse->getOrderList() as $order) { |
||
35 | echo "-----\n"; |
||
36 | echo "Symbol: {$order->getSymbol()}\n"; |
||
37 | echo "Order ID: {$order->getOrderId()}\n"; |
||
38 | echo "Order Link ID: {$order->getOrderLinkId()}\n"; |
||
39 | echo "Side: {$order->getSide()}\n"; |
||
40 | echo "Order Type: {$order->getOrderType()}\n"; |
||
41 | echo "Order price: {$order->getPrice()}\n"; |
||
42 | echo "Order Quantity: {$order->getQty()}\n"; |
||
43 | echo "Time In Force: {$order->getTimeInForce()}\n"; |
||
44 | echo "Order Status: {$order->getOrderStatus()}\n"; |
||
45 | echo "Position Index: {$order->getPositionIdx()}\n"; |
||
46 | echo "Last Price On Created: {$order->getLastPriceOnCreated()}\n"; |
||
47 | echo "Created Time: {$order->getCreatedTime()->format('Y-m-d H:i:s')}\n"; |
||
48 | echo "Updated Time: {$order->getUpdatedTime()->format('Y-m-d H:i:s')}\n"; |
||
49 | echo "Cancel Type: {$order->getCancelType()}\n"; |
||
50 | echo "Reject Reason: {$order->getRejectReason()}\n"; |
||
51 | echo "Stop Order Price: {$order->getStopOrderType()}\n"; |
||
52 | echo "Trigger Direction: {$order->getTriggerDirection()}\n"; |
||
53 | echo "Trigger By: {$order->getTriggerBy()}\n"; |
||
54 | echo "Trigger Price: {$order->getTriggerPrice()}\n"; |
||
55 | echo "Cumulative Executed Fee: {$order->getCumExecFee()}\n"; |
||
56 | echo "Cumulative Executed Value: {$order->getCumExecValue()}\n"; |
||
57 | echo "Cumulative Executed Quantity: {$order->getCumExecQty()}\n"; |
||
58 | echo "Leaves Value {$order->getLeavesValue()}\n"; |
||
59 | echo "Leaves Quantity: {$order->getLeavesQty()}\n"; |
||
60 | echo "Take Profit: {$order->getTakeProfit()}\n"; |
||
61 | echo "Stop Loss: {$order->getStopLoss()}\n"; |
||
62 | echo "TP/SL Mode: {$order->getTpslMode()}\n"; |
||
63 | echo "Take Profit Limit Price: {$order->getTpLimitPrice()}\n"; |
||
64 | echo "Stop-Loss Limit Price: {$order->getSlLimitPrice()}\n"; |
||
65 | echo "Take Profit Trigger By {$order->getTpTriggerBy()}\n"; |
||
66 | echo "Stop-Loss Trigger By {$order->getSlTriggerBy()}\n"; |
||
67 | echo "Reduce Only: {$order->isReduceOnly()}\n"; |
||
68 | echo "Close On Trigger: {$order->isCloseOnTrigger()} {}\n"; |
||
69 | echo "Block Trade ID: {$order->getBlockTradeId()}\n"; |
||
70 | } |
||
150 | } |