Test Failed
Push — master ( 55431f...64d5a8 )
by Jeff
04:55
created

CheckoutRepository::buildCheckoutItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 1
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
namespace App\Shop\Checkout;
4
5
use App\Shop\Carts\Repositories\CartRepository;
6
use App\Shop\Carts\ShoppingCart;
7
use App\Shop\OrderDetails\OrderProduct;
8
use App\Shop\OrderDetails\Repositories\OrderProductRepository;
9
use App\Shop\Orders\Order;
10
use App\Shop\Orders\Repositories\OrderRepository;
11
12
class CheckoutRepository
13
{
14
    /**
15
     * @param array $data
16
     * @return Order
17
     */
18
    public function buildCheckoutItems(array $data) : Order
19
    {
20
        $orderRepo = new OrderRepository(new Order);
21
        $cartRepo = new CartRepository(new ShoppingCart);
22
        $orderProductRepo = new OrderProductRepository(new OrderProduct);
23
24
        $order = $orderRepo->create([
25
            'reference' => $data['reference'],
26
            'courier_id' => $data['courier_id'],
27
            'customer_id' => $data['customer_id'],
28
            'address_id' => $data['address_id'],
29
            'order_status_id' => $data['order_status_id'],
30
            'payment' => $data['payment'],
31
            'discounts' => $data['discounts'],
32
            'total_products' => $data['total_products'],
33
            'total' => $data['total'],
34
            'total_paid' => $data['total_paid'],
35
            'tax' => $data['tax']
36
        ]);
37
38
        $orderProductRepo->buildOrderDetails($order, $cartRepo->getCartItems());
39
40
        return $order;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $order returns the type Illuminate\Database\Eloquent\Model which includes types incompatible with the type-hinted return App\Shop\Orders\Order.
Loading history...
41
    }
42
}
43