CartItem   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 47
rs 10
ccs 18
cts 18
cp 1
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getAmount() 0 3 1
A getQuantity() 0 3 1
A getName() 0 3 1
A getDescription() 0 3 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway;
4
5
class CartItem
6
{
7
8
	/** @var string */
9
	private $name;
10
11
	/** @var int */
12
	private $quantity;
13
14
	/** @var int */
15
	private $amount;
16
17
	/** @var string|null */
18
	private $description;
19
20 4
	public function __construct(string $name, int $quantity, int $amount, ?string $description = null)
21
	{
22 4
		Validator::checkCartItemName($name);
23 4
		if ($description !== null) {
24 3
			Validator::checkCartItemDescription($description);
25
		}
26 4
		Validator::checkCartItemQuantity($quantity);
27
28 3
		$this->name = $name;
29 3
		$this->quantity = $quantity;
30 3
		$this->amount = $amount;
31 3
		$this->description = $description;
32 3
	}
33
34 1
	public function getName(): string
35
	{
36 1
		return $this->name;
37
	}
38
39 1
	public function getQuantity(): int
40
	{
41 1
		return $this->quantity;
42
	}
43
44 1
	public function getAmount(): int
45
	{
46 1
		return $this->amount;
47
	}
48
49 2
	public function getDescription(): ?string
50
	{
51 2
		return $this->description;
52
	}
53
54
}
55