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

CartService::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 0
cts 7
cp 0
crap 6
rs 10
c 0
b 0
f 0
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