Passed
Push — master ( 33b9bf...a11b84 )
by Dariusz
03:33 queued 10s
created

CartCommon   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 78.56%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 0
dl 0
loc 87
ccs 33
cts 42
cp 0.7856
rs 10
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrency() 0 4 1
A setShipping() 0 4 1
A getShipping() 0 4 1
A setPayment() 0 4 1
A getPayment() 0 4 1
A addDiscount() 0 4 1
A getDiscounts() 0 4 1
A fill() 0 4 1
A add() 0 4 1
A remove() 0 4 1
A clear() 0 4 1
A update() 0 4 1
A has() 0 4 1
A get() 0 4 1
A items() 0 4 1
A itemsQuantity() 0 4 1
A weight() 0 4 1
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the Plane\Shop package.
5
 *
6
 * (c) Dariusz Korsak <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Plane\Shop\Traits;
13
14
use Plane\Shop\PaymentInterface;
15
use Plane\Shop\CartItemInterface;
16
use Plane\Shop\ShippingInterface;
17
use Plane\Shop\CartItemCollection;
18
use Plane\Shop\CartDiscountInterface;
19
20
trait CartCommon
21
{
22 2
    public function getCurrency(): string
23
    {
24 2
        return $this->cart->getCurrency();
0 ignored issues
show
Bug introduced by
The property cart does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
    }
26
27 13
    public function setShipping(ShippingInterface $shipping): void
28
    {
29 13
        $this->cart->setShipping($shipping);
30 13
    }
31
    
32 2
    public function getShipping(): ?ShippingInterface
33
    {
34 2
        return $this->cart->getShipping();
35
    }
36
    
37 13
    public function setPayment(PaymentInterface $payment): void
38
    {
39 13
        $this->cart->setPayment($payment);
40 13
    }
41
    
42 2
    public function getPayment(): ?PaymentInterface
43
    {
44 2
        return $this->cart->getPayment();
45
    }
46
    
47
    public function addDiscount(CartDiscountInterface $discount): void
48
    {
49
        $this->cart->addDiscount($discount);
50
    }
51
52 1
    public function getDiscounts(): array
53
    {
54 1
        return $this->cart->getDiscounts();
55
    }
56
57
    public function fill(CartItemCollection $collection): void
58
    {
59
        $this->cart->fill($collection);
60
    }
61
    
62
    public function add(CartItemInterface $item): void
63
    {
64
        $this->cart->add($item);
65
    }
66
    
67 2
    public function remove(string $itemId): void
68
    {
69 2
        $this->cart->remove($itemId);
70 1
    }
71
72 1
    public function clear(): void
73
    {
74 1
        $this->cart->clear();
75 1
    }
76
77 1
    public function update(CartItemInterface $item): void
78
    {
79 1
        $this->cart->update($item);
80 1
    }
81
    
82 2
    public function has(string $itemId): bool
83
    {
84 2
        return $this->cart->has($itemId);
85
    }
86
    
87 2
    public function get(string $itemId): CartItemInterface
88
    {
89 2
        return $this->cart->get($itemId);
90
    }
91
    
92 3
    public function items(): array
93
    {
94 3
        return $this->cart->items();
95
    }
96
    
97 2
    public function itemsQuantity(): int
98
    {
99 2
        return $this->cart->itemsQuantity();
100
    }
101
    
102 1
    public function weight(): string
103
    {
104 1
        return $this->cart->weight();
105
    }
106
}
107