Completed
Push — master ( de0635...69f45f )
by Leith
17:25
created

ItemBag   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 21
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
    public function add($item)
18
    {
19
        if ($item instanceof Item) {
20
            $this->items[] = $item;
21
        } else if ($item instanceof ItemInterface) {
22
            $this->items[] = new Item([
23
                'name'        => $item->getName(),
24
                'description' => $item->getDescription(),
25
                'quantity'    => $item->getQuantity(),
26
                'price'       => $item->getPrice(),
27
            ]);
28
        } else {
29
            $this->items[] = new Item($item);
30
        }
31
    }
32
}
33