Conditions | 3 |
Paths | 2 |
Total Lines | 51 |
Code Lines | 40 |
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 |
||
13 | public function testSuccessEndpoint() |
||
14 | { |
||
15 | echo "\n //// --- //// \n"; |
||
16 | |||
17 | $bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ'); |
||
18 | |||
19 | $response = $bybit->privateEndpoint( |
||
20 | GetClosedPnL::class, |
||
21 | (new GetClosedPnLRequest()) |
||
22 | ->setSymbol('BTCUSDT') |
||
23 | ->setLimit(2) |
||
24 | )->execute(); |
||
25 | |||
26 | if ($response->getReturnCode()) { |
||
27 | echo "CODE: {$response->getReturnCode()} \n"; |
||
28 | echo "MESSAGE: {$response->getReturnMessage()} \n"; |
||
29 | |||
30 | /** @var IGetClosedPnLResponseInterface $pnlInfoResponse */ |
||
31 | $pnlInfoResponse = $response->getResult(); |
||
32 | echo "Next page cursor: {$pnlInfoResponse->getNextPageCursor()}\n"; |
||
33 | echo "----\n"; |
||
34 | foreach ($pnlInfoResponse->getClosedPnlList() as $pnl) { |
||
35 | echo "----\n"; |
||
36 | echo "Symbol: {$pnl->getSymbol()}\n"; |
||
37 | echo "Order ID: {$pnl->getOrderId()}\n"; |
||
38 | echo "Side: {$pnl->getSide()}\n"; |
||
39 | echo "Quantity: {$pnl->getQty()}\n"; |
||
40 | echo "Leverage: {$pnl->getLeverage()}\n"; |
||
41 | echo "Order Price: {$pnl->getOrderPrice()}\n"; |
||
42 | echo "Order Type: {$pnl->getOrderType()}\n"; |
||
43 | echo "Executed Type: {$pnl->getExecType()}\n"; |
||
44 | echo "Closed Size: {$pnl->getClosedSize()}\n"; |
||
45 | echo "Cumulative Entry Value: {$pnl->getCumEntryValue()}\n"; |
||
46 | echo "Average Entry Price: {$pnl->getAvgEntryPrice()}\n"; |
||
47 | echo "Cumulative Exit Value {$pnl->getCumExitValue()}\n"; |
||
48 | echo "Average Exit Price: {$pnl->getAvgExitPrice()}\n"; |
||
49 | echo "Closed PnL: {$pnl->getClosedPnl()}\n"; |
||
50 | echo "Filled Count: {$pnl->getFillCount()}\n"; |
||
51 | echo "Created At: {$pnl->getCreatedAt()->format('Y-m-d H:i:s')}\n"; |
||
52 | echo "Created Time: {$pnl->getCreatedTime()->format('Y-m-d H:i:s')}\n"; |
||
53 | echo "Updated Time: {$pnl->getUpdatedTime()->format('Y-m-d H:i:s')}\n"; |
||
54 | } |
||
55 | } else { |
||
56 | echo "API ERORR: " . get_class($this) . "\n"; |
||
57 | echo "CODE: {$response->getReturnCode()} \n"; |
||
58 | echo "MESSAGE: {$response->getReturnMessage()} \n"; |
||
59 | echo "EXTENDED:" . implode(";\n", $response->getExtendedInfo()) . "\n"; |
||
60 | } |
||
61 | |||
62 | |||
63 | $this->assertTrue(true); |
||
64 | } |
||
66 |