Completed
Pull Request — master (#6)
by Rafael
04:31
created

setOrderStatusToDeliveryFailedFromVenture()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Iris\SaleWrapper;
4
5
use \Iris\Mapping\Order;
6
7
class Partner extends Base implements PartnerInterface
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: confirmReserveAndUpdateStock, setNfeKeyAndTrackingUrl
Loading history...
8
{
9
    /**
10
     * Gets Venture service.
11
     * @return Iris\Interfaces\IrisVenture
12
     */
13
    public function getVentureService()
14 4
    {
15
        return $this->getManager()->getService(\Iris\Factory::VENTURE);
16 4
    }
17
18
    /**
19
     * Gets Stock service.
20
     * @return Iris\Interfaces\Stock
21
     */
22
    public function getStockService()
23 3
    {
24
        return $this->getManager()->getService(\Iris\Factory::STOCK);
25 3
    }
26
27
    /**
28
     * Gets Stock service.
29
     * @return Iris\Interfaces\Catalog
30
     */
31
    public function getCatalogService()
32 2
    {
33
        return $this->getManager()->getService(\Iris\Factory::CATALOG);
34 2
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function dropReserveAndUpdateStock(
40 2
        \Iris\Transfer\Sales\Order\Item $orderItem,
41
        \Iris\Transfer\Catalog\Simple $product
42 2
    ) {
43 2
        $this->getStockService()->dropReserve($orderItem);
0 ignored issues
show
Bug introduced by
The method dropReserve() does not seem to exist on object<Iris\Interfaces\Service>.

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...
44 2
        $this->updateStockFromVenture($product);
0 ignored issues
show
Bug introduced by
The call to updateStockFromVenture() misses a required argument $ventureCode.

This check looks for function calls that miss required arguments.

Loading history...
Documentation introduced by
$product is of type object<Iris\Transfer\Catalog\Simple>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
    }
46
47
    /**
48
     * {@inheritdoc}
49 1
     */
50
    public function isVentureItem(\Iris\Transfer\Sales\Order\Item $item)
51 1
    {
52
        $irisVenture = $this->getVentureService()
0 ignored issues
show
Bug introduced by
The method getIrisVentureBySalesOrderId() does not seem to exist on object<Iris\Interfaces\Service>.

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...
53 1
            ->getIrisVentureBySalesOrderId($item->getFkSalesOrder());
54 1
55 1
        return ($irisVenture instanceof \Iris\Transfer\Venture);
56 1
    }
57
58 1
    /**
59
     * {@inheritdoc}
60 1
     */
61 1
    public function sendOrderToVenture(
62
        \Iris\Transfer\Sales\Order $order, 
63
        \Iris\Transfer\Venture $venture
64
    ) {
65
        $mappedOrder = $this->getOrderMapping()->map($order);
66 1
67
        return $this->getPartnerApiClient()
68 1
            ->createOrderOnVenture($venture, $mappedOrder);
0 ignored issues
show
Documentation introduced by
$venture is of type object<Iris\Transfer\Venture>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
69 1
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function confirmOrderPaidOnVenture(
75 1
        \Iris\Transfer\Sales\Order $order, 
76
        \Iris\Transfer\Venture $venture
77 1
    ) {
78 1
        return $this->getPartnerApiClient()
79
            ->confirmPaymentOnVenture(
80
                $venture->getVentureCode(), 
81
                $order->getOrderNr()
82
            );
83
    }
84 4
85
    /**
86 4
     * {@inheritdoc}
87
     */
88
    public function cancelOrderOnVenture(
89
        \Iris\Transfer\Sales\Order $order,
90
        \Iris\Transfer\Venture $venture
91
    ) {
92 1
        return $this->getPartnerApiClient()
93
            ->cancelOrderOnVenture(
94 1
                $venture->getVentureCode(),
95
                $order->getOrderNr()
96 1
            );
97 1
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function cancelOrderFromVenture($orderNr, $ventureCode) {
103 1
        
104
        $order = $this->getOrderService()
105 1
            ->getOrderByOrderNumberAndVentureCode($orderNr, $ventureCode);
106 1
107
        $this->getOrderService()->cancelOrderFromVenture($order);
108
        return ['order_number' => $order->getOrderNr()];
109
    }
110
111
    /**
112 1
     * {@inheritdoc}
113
     */
114 1
    public function getName()
115 1
    {
116
        return 'partner';
117
    }
118
119
    /**
120
     * {@inheritdoc}
121 1
     */
122
    public function setOrderStatusToShippedFromVenture(array $orderData) 
123 1
    {
124 1
        $order = \Iris\Mapping\Order::assign($orderData);
125 1
126 1
        foreach ($order->getItemCollection() as $item) {
127 1
            if (!$item->getTrackingCode()) {
128 1
                $item->setTrackingCode(md5($item->getTrackingUrl()));         
129 1
            }
130
        }
131
132
        return $this->getOrderService()->shippedByVenture($salesOrder);
0 ignored issues
show
Bug introduced by
The variable $salesOrder does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
133
    }
134
135 2
    /**
136
     * {@inheritdoc}
137 2
     */
138
    public function setOrderStatusToDeliveredFromVenture(array $orderData) 
139
    {
140
        $order = \Iris\Mapping\Order::assign($orderData);
141
        return $this->getOrderService()->deliveredByVenture($order, $venture);
0 ignored issues
show
Bug introduced by
The variable $venture does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
142
    }
143
144
    /**
145
     * {@inheritdoc}
146
     */
147
    public function setOrderStatusToDeliveryFailedFromVenture(array $orderData)
148
    {
149
        $order = \Iris\Mapping\Order::assign($orderData);
150
        return $this->getOrderService()
151
            ->deliveryFailedByVenture($order, $venture);
0 ignored issues
show
Bug introduced by
The variable $venture does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     */
157
    public function isInvalidOrder(\Iris\Transfer\Sales\Order $order)
158
    {
159
        return $this->getOrderService()->isInvalidOrder($order);
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function bindVentureOrder($orderNumber, $ventureCode, $ventureOrderNumber)
166
    {
167
        $venture = $this->getVentureService()->findByCode($ventureCode);
0 ignored issues
show
Bug introduced by
The method findByCode() does not seem to exist on object<Iris\Interfaces\Service>.

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...
Unused Code introduced by
$venture is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
168
169
        $order = $this->getOrderService()
0 ignored issues
show
Unused Code introduced by
$order is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
170
            ->getOrderByOrderNumberAndVentureCode(
171
                $orderNumber,
172
                $ventureCode
173
            );
174
175
        $this->getVentureService()
0 ignored issues
show
Bug introduced by
The method bindPartnerOrderWithVentureOrder() does not seem to exist on object<Iris\Interfaces\Service>.

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...
176
            ->bindPartnerOrderWithVentureOrder(
177
                $orderNumber,
178
                $ventureCode,
179
                $ventureOrderNumber
180
            );
181
    }
182
183
    /**
184
     * {@inheritdoc}
185
     */
186
    public function updatePriceFromVenture(array $productsData, $ventureCode)
187
    {
188
        $configCollection = \Iris\Mapping\ConfigCollection::assign($productsData);
189
        return $this->getCatalogService()->updatePrice($configCollection);
0 ignored issues
show
Bug introduced by
The method updatePrice() does not seem to exist on object<Iris\Interfaces\Service>.

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...
190
    }
191
192
    /**
193
     * {@inheritdoc}
194
     */
195
    public function updateStockFromVenture(array $productsData, $ventureCode)
196
    {
197
        $configCollection = \Iris\Mapping\ConfigCollection::assign($productsData);
198
        return $this->getStockService()
0 ignored issues
show
Bug introduced by
The method updateAbsoluteStock() does not seem to exist on object<Iris\Interfaces\Service>.

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...
199
            ->updateAbsoluteStock($configCollection);
200
    }
201
202
    /**
203
     * {@inheritdoc}
204
     */
205
    public function createProductsFromVenture(array $productsData, $ventureCode)
206
    {
207
        $configCollection = \Iris\Mapping\ConfigCollection::assign($productsData);
0 ignored issues
show
Unused Code introduced by
$configCollection is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
208
        //@todo
209
    }
210
211
    /**
212
     * {@inheritdoc}
213
     */
214
    public function updateProductsFromVenture(array $productsData, $ventureCode)
215
    {
216
        $configCollection = \Iris\Mapping\ConfigCollection::assign($productsData);
0 ignored issues
show
Unused Code introduced by
$configCollection is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
217
        //@todo
218
    }
219
220
    /**
221
     * {@inheritdoc}
222
     */
223
    public function handleImages(\Iris\Transfer\Catalog\Config $config) 
224
    {
225
        //@todo
226
    }
227
}
228