CartItem::getQuantity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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