Completed
Pull Request — master (#40)
by Бабичев
06:12
created

CartService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 14
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 2
1
<?php
2
3
namespace Bavix\Wallet\Services;
4
5
use Bavix\Wallet\Interfaces\Product;
6
use Bavix\Wallet\Objects\Cart;
7
8
class CartService
9
{
10
11
    /**
12
     * @param Product[] $products
13
     * @return Cart
14
     */
15
    public function create(array $products = []): Cart
16
    {
17
        $cart = new Cart();
18
        foreach ($products as $product) {
19
            $cart->addItem($product);
20
        }
21
        return $cart;
22
    }
23
24
}
25