$this->child_item_id, 'child_item_code' => $this->child_item_code, 'lot_prefix' => $this->lot_prefix, 'part_type' => $this->part_type, 'category' => $this->category, 'material_type' => $this->material_type, 'length_mm' => $this->length_mm, 'qty' => $this->qty, ]; } /** * 필수 필드 검증 * * @throws InvalidArgumentException */ public static function validate(array $data): bool { $required = ['child_item_id', 'child_item_code', 'lot_prefix', 'part_type', 'category', 'material_type', 'length_mm', 'qty']; foreach ($required as $field) { if (! array_key_exists($field, $data) || $data[$field] === null) { throw new InvalidArgumentException("DynamicBomEntry: '{$field}' is required"); } } if ((int) $data['child_item_id'] <= 0) { throw new InvalidArgumentException('DynamicBomEntry: child_item_id must be positive'); } $validCategories = ['guideRail', 'bottomBar', 'shutterBox', 'smokeBarrier']; if (! in_array($data['category'], $validCategories, true)) { throw new InvalidArgumentException('DynamicBomEntry: category must be one of: '.implode(', ', $validCategories)); } if ($data['qty'] <= 0) { throw new InvalidArgumentException('DynamicBomEntry: qty must be positive'); } return true; } /** * DynamicBomEntry 배열 → JSON 저장용 배열 변환 * * @param DynamicBomEntry[] $entries */ public static function toArrayList(array $entries): array { return array_map(fn (self $e) => $e->toArray(), $entries); } }