Passed
Push — master ( 98de4f...224db0 )
by Thiago
30s
created

Cart   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 4 1
A removeItem() 0 8 2
1
<?php
2
namespace MrPrompt\ShipmentCommon\Base;
3
4
use ArrayObject;
5
6
/**
7
 * Cart
8
 *
9
 * @author Thiago Paes <[email protected]>
10
 */
11
class Cart extends ArrayObject
12
{
13
    /**
14
     * @param mixed $item
15
     */
16 1
    public function addItem($item)
17
    {
18 1
        $this->append($item);
19 1
    }
20
21
    /**
22
     * @param mixed $item
23
     */
24 2
    public function removeItem($item)
25
    {
26 2
        if (!$this->offsetExists($item)) {
27 1
            throw new \InvalidArgumentException(sprintf('Item "%s" not exists', $item));
28
        }
29
30 1
        $this->offsetUnset($item);
31
    }
32
}