Test Failed
Pull Request — master (#20)
by Vladislav
02:31
created

GetOrderListTest::testSuccessEndpoint()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 56
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 47
nc 2
nop 0
dl 0
loc 56
rs 9.1563
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Tests;
3
4
use Carpenstar\ByBitAPI\BybitAPI;
5
use Carpenstar\ByBitAPI\Core\Interfaces\IResponseInterface;
0 ignored issues
show
Bug introduced by
The type Carpenstar\ByBitAPI\Core...aces\IResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\GetOrderList;
7
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces\IGetOrderListResponseItemInterface;
8
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Request\GetOrderListRequest;
9
use Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Response\GetOrderListResponse;
10
use PHPUnit\Framework\TestCase;
11
12
class GetOrderListTest extends TestCase
13
{
14
    public function testSuccessEndpoint()
15
    {
16
$bybitApi = (new BybitAPI())
0 ignored issues
show
Bug introduced by
The call to Carpenstar\ByBitAPI\BybitAPI::__construct() has too few arguments starting with host. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
$bybitApi = (/** @scrutinizer ignore-call */ new BybitAPI())

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.

Loading history...
17
    ->setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ');
0 ignored issues
show
Bug introduced by
The method setCredentials() does not exist on Carpenstar\ByBitAPI\BybitAPI. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
    ->/** @scrutinizer ignore-call */ setCredentials('https://api-testnet.bybit.com', 'fL02oi5qo8i2jDxlum', 'Ne1EE35XTprIWrId9vGEAc1ZYJTmodA4qFzZ');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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
}
71
72
/**
73
 * Return code: 0
74
 * Return message: OK
75
 * Product Category:
76
 * Next Page Cursor: eyJza2lwX2xvY2FsX3N5bWJvbCI6ZmFsc2UsInBhZ2VfdG9rZW4iOiIzODA1NCJ9
77
 * Order List:
78
 * -----
79
 *  Symbol: BTCUSDT
80
 *  Order ID: 55b6ef38-689e-46c0-a55b-e7124f90004a
81
 *  Order Link ID:
82
 *  Side: Sell
83
 *  Order Type: Limit
84
 *  Order price: 66037
85
 *  Order Quantity: 0.001
86
 *  Time In Force: GoodTillCancel
87
 *  Order Status: Filled
88
 *  Position Index: 0
89
 *  Last Price On Created: 0
90
 *  Created Time: 2024-06-18 21:11:47
91
 *  Updated Time: 2024-06-20 10:57:59
92
 *  Cancel Type: UNKNOWN
93
 *  Reject Reason: EC_NoError
94
 *  Stop Order Price: UNKNOWN
95
 *  Trigger Direction: 0
96
 *  Trigger By: UNKNOWN
97
 *  Trigger Price: 0
98
 *  Cumulative Executed Fee: 0.0132074
99
 *  Cumulative Executed Value: 66.037
100
 *  Cumulative Executed Quantity: 0.001
101
 *  Leaves Value 0
102
 *  Leaves Quantity: 0
103
 *  Take Profit: 0
104
 *  Stop Loss: 0
105
 *  TP/SL Mode:
106
 *  Take Profit Limit Price: 0
107
 *  Stop-Loss Limit Price: 0
108
 *  Take Profit Trigger By UNKNOWN
109
 *  Stop-Loss Trigger By UNKNOWN
110
 *  Reduce Only:
111
 *  Close On Trigger:  {}
112
 *  Block Trade ID:
113
 *  -----
114
 *  Symbol: BTCUSDT
115
 *  Order ID: 4f279264-6d38-46c1-8216-7e5a2f110c11
116
 *  Order Link ID:
117
 *  Side: Sell
118
 *  Order Type: Limit
119
 *  Order price: 67037
120
 *  Order Quantity: 0.001
121
 *  Time In Force: GoodTillCancel
122
 *  Order Status: New
123
 *  Position Index: 0
124
 *  Last Price On Created: 0
125
 *  Created Time: 2024-06-18 21:11:43
126
 *  Updated Time: 2024-06-18 21:11:43
127
 *  Cancel Type: UNKNOWN
128
 *  Reject Reason: EC_NoError
129
 *  Stop Order Price: UNKNOWN
130
 *  Trigger Direction: 0
131
 *  Trigger By: UNKNOWN
132
 *  Trigger Price: 0
133
 *  Cumulative Executed Fee: 0
134
 *  Cumulative Executed Value: 0
135
 *  Cumulative Executed Quantity: 0
136
 *  Leaves Value 67.037
137
 *  Leaves Quantity: 0.001
138
 *  Take Profit: 0
139
 *  Stop Loss: 0
140
 *  TP/SL Mode:
141
 *  Take Profit Limit Price: 0
142
 *  Stop-Loss Limit Price: 0
143
 *  Take Profit Trigger By UNKNOWN
144
 *  Stop-Loss Trigger By UNKNOWN
145
 *  Reduce Only:
146
 *  Close On Trigger:  {}
147
 *  Block Trade ID:
148
 **/
149
150
    }
151
}