amount = $amount; $this->unitOfMeasure = $unitOfMeasure; $this->unitSize = $unitSize; } public function getAmount(): int { return $this->amount; } public function getUnitOfMeasure(): string { return $this->unitOfMeasure; } public function getUnitSize(): int { return $this->unitSize; } public function toArray(): array { return [ 'amount' => $this->amount, 'unitOfMeasure' => $this->unitOfMeasure, 'unitSize' => $this->unitSize, ]; } public static function fromArray(array $data) { return new static( $data['amount'], $data['unitOfMeasure'], isset($data['unitSize']) ? $data['unitSize'] : null ); } }