Completed
Push — master ( 9be2e3...3a8fde )
by Gaël
14:21
created

CartResource::addItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
4
namespace DansMaCulotte\Monetico\Resources;
5
6
use DansMaCulotte\Monetico\Exceptions\Exception;
7
8
class CartResource extends Ressource
9
{
10
    const ITEMS_KEY = 'shoppingCartItems';
11
12
    /** @var array */
13
    protected $keys = [
14
        'giftCardAmount',
15
        'giftCardCount',
16
        'giftCardCurrency',
17
        'preOrderDate',
18
        'preorderIndicator',
19
        'shoppingCartItems',
20
    ];
21
22
    /**
23
     * Client constructor.
24
     *
25
     * @param array $fields
26
     * @throws Exception
27
     */
28
    public function __construct(array $fields = [])
29
    {
30
        parent::__construct(array_merge(
31
            $fields,
32
            [
33
                self::ITEMS_KEY => [],
34
            ]
35
        ));
36
    }
37
38
    /**
39
     * @param CartItemResource $item
40
     */
41
    public function addItem(CartItemResource $item): void
42
    {
43
        array_push($this->parameters[self::ITEMS_KEY], $item->getParameters());
44
    }
45
}
46