-
Notifications
You must be signed in to change notification settings - Fork 14
/
ShipmentItem.php
49 lines (39 loc) · 1.19 KB
/
ShipmentItem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace inklabs\kommerce\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class ShipmentItem implements IdEntityInterface
{
use IdTrait, TimeTrait;
/** @var OrderItem */
protected $orderItem;
/** @var int */
protected $quantityToShip;
/** @var Shipment */
protected $shipment;
public function __construct(Shipment $shipment, OrderItem $orderItem, int $quantityToShip)
{
$this->setId();
$this->setCreated();
$this->orderItem = $orderItem;
$this->quantityToShip = $quantityToShip;
$shipment->addShipmentItem($this);
$this->shipment = $shipment;
}
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('quantityToShip', new Assert\NotNull);
$metadata->addPropertyConstraint('quantityToShip', new Assert\Range([
'min' => 0,
'max' => 65535,
]));
}
public function getOrderItem(): OrderItem
{
return $this->orderItem;
}
public function getQuantityToShip(): int
{
return $this->quantityToShip;
}
}