Conditions | 2 |
Paths | 2 |
Total Lines | 81 |
Code Lines | 22 |
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 |
||
12 | public function testSuccessEndpoint() |
||
13 | { |
||
14 | $bybit = (new BybitAPI())->setCredentials('https://api-testnet.bybit.com','fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ'); |
||
15 | |||
16 | $response = $bybit->privateEndpoint(WalletBalance::class, (new WalletBalanceRequest()))->execute(); |
||
17 | |||
18 | echo "Return code: {$response->getReturnCode()} \n"; |
||
19 | echo "Return message: {$response->getReturnMessage()} \n"; |
||
20 | |||
21 | $walletBalances = array_slice($response->getResult()->getBalances(), 0, 3); |
||
22 | |||
23 | /** @var IWalletBalanceResponseItemInterface $balance */ |
||
24 | foreach ($walletBalances as $balance) { |
||
25 | echo "----- \n"; |
||
26 | echo "Coin: {$balance->getCoin()} \n"; |
||
27 | echo "Equity: {$balance->getEquity()} \n"; |
||
28 | echo "Wallet Balance: {$balance->getWalletBalance()} \n"; |
||
29 | echo "Position Margin: {$balance->getPositionMargin()} \n"; |
||
30 | echo "Available Balance: {$balance->getAvailableBalance()} \n"; |
||
31 | echo "Order Margin: {$balance->getOrderMargin()} \n"; |
||
32 | echo "Occ Closing Fee: {$balance->getOccClosingFee()} \n"; |
||
33 | echo "Occ Funding Fee: {$balance->getOccFundingFee()} \n"; |
||
34 | echo "Unrealised PnL: {$balance->getUnrealisedPnl()} \n"; |
||
35 | echo "Cumulative Realised PnL: {$balance->getCumRealisedPnl()} \n"; |
||
36 | echo "Given Cash: {$balance->getGivenCash()} \n"; |
||
37 | echo "Service Cash: {$balance->getServiceCash()} \n"; |
||
38 | echo "Account IM: {$balance->getAccountIM()} \n"; |
||
39 | echo "Account MM: {$balance->getAccountMM()} \n"; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Return code: 0 |
||
44 | * Return message: OK |
||
45 | * ----- |
||
46 | * Coin: BTC |
||
47 | * Equity: 0.2 |
||
48 | * Wallet Balance: 0.2 |
||
49 | * Position Margin: 0 |
||
50 | * Available Balance: 0.2 |
||
51 | * Order Margin: 0 |
||
52 | * Occ Closing Fee: 0 |
||
53 | * Occ Funding Fee: 0 |
||
54 | * Unrealised PnL: 0 |
||
55 | * Cumulative Realised PnL: 0 |
||
56 | * Given Cash: 0 |
||
57 | * Service Cash: 0 |
||
58 | * Account IM: |
||
59 | * Account MM: |
||
60 | * ----- |
||
61 | * Coin: ETH |
||
62 | * Equity: 0 |
||
63 | * Wallet Balance: 0 |
||
64 | * Position Margin: 0 |
||
65 | * Available Balance: 0 |
||
66 | * Order Margin: 0 |
||
67 | * Occ Closing Fee: 0 |
||
68 | * Occ Funding Fee: 0 |
||
69 | * Unrealised PnL: 0 |
||
70 | * Cumulative Realised PnL: 0 |
||
71 | * Given Cash: 0 |
||
72 | * Service Cash: 0 |
||
73 | * Account IM: |
||
74 | * Account MM: |
||
75 | * ----- |
||
76 | * Coin: EOS |
||
77 | * Equity: 0 |
||
78 | * Wallet Balance: 0 |
||
79 | * Position Margin: 0 |
||
80 | * Available Balance: 0 |
||
81 | * Order Margin: 0 |
||
82 | * Occ Closing Fee: 0 |
||
83 | * Occ Funding Fee: 0 |
||
84 | * Unrealised PnL: 0 |
||
85 | * Cumulative Realised PnL: 0 |
||
86 | * Given Cash: 0 |
||
87 | * Service Cash: 0 |
||
88 | * Account IM: |
||
89 | * Account MM: |
||
90 | */ |
||
91 | |||
92 | $this->assertTrue(true); |
||
93 | } |
||
95 | } |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.