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

Cart::removeItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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