ItemBag   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 15 3
1
<?php
2
3
namespace Omnipay\CapitaPay360;
4
5
use Omnipay\Common\ItemBag as BaseItemBag;
6
use Omnipay\Common\ItemInterface;
7
use Omnipay\CapitaPay360\Item;
8
9
/**
10
 * Capita Pay360 collection of sale line items
11
 */
12
class ItemBag extends BaseItemBag
13
{
14
    /**
15
     * Override {@see Omnipay\Common\ItemBag::add()} to use custom {@see Omnipay\CapitaPay360\Item} class
16
     */
17 4
    public function add($item)
18
    {
19 4
        if ($item instanceof Item) {
20 1
            $this->items[] = $item;
21 3
        } elseif ($item instanceof ItemInterface) {
22 1
            $this->items[] = new Item(array(
23 1
                'name'        => $item->getName(),
24 1
                'description' => $item->getDescription(),
25 1
                'quantity'    => $item->getQuantity(),
26 1
                'price'       => $item->getPrice(),
27
            ));
28
        } else {
29 2
            $this->items[] = new Item($item);
30
        }
31 4
    }
32
}
33