1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* You can find more information about us on https://bitbag.io and write us |
7
|
|
|
* an email on [email protected]. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace BitBag\SyliusMolliePlugin\DTO; |
13
|
|
|
|
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
15
|
|
|
use Doctrine\Common\Collections\Collection; |
16
|
|
|
|
17
|
|
|
final class PartialRefundItems |
18
|
|
|
{ |
19
|
|
|
/** @var Collection */ |
20
|
|
|
private $partialRefundItems; |
21
|
|
|
|
22
|
|
|
public function __construct() |
23
|
|
|
{ |
24
|
|
|
$this->partialRefundItems = new ArrayCollection(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function getPartialRefundItems(): Collection |
28
|
|
|
{ |
29
|
|
|
return $this->partialRefundItems; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function setPartialRefundItems(PartialRefundItem $partialRefundItem): void |
33
|
|
|
{ |
34
|
|
|
$this->partialRefundItems->add($partialRefundItem); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function addPartialRefundItemByQuantity(int $id, string $type, int $quantity): void |
38
|
|
|
{ |
39
|
|
|
for ($oneItem = 0; $oneItem < $quantity; ++$oneItem) { |
40
|
|
|
$partialRefundItem = new PartialRefundItem(); |
41
|
|
|
$partialRefundItem->setId($id); |
42
|
|
|
$partialRefundItem->setType($type); |
43
|
|
|
|
44
|
|
|
$this->partialRefundItems->add($partialRefundItem); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function findById(int $id): ?PartialRefundItem |
49
|
|
|
{ |
50
|
|
|
foreach ($this->getPartialRefundItems() as $item) { |
51
|
|
|
if ($id === $item->getId()) { |
52
|
|
|
return $item; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return null; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function removeItem(PartialRefundItem $partialRefundItem): void |
60
|
|
|
{ |
61
|
|
|
$this->getPartialRefundItems()->removeElement($partialRefundItem); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|