<?php

namespace Kylin\Logistics\Enums;

/**
 * 货物类型枚举
 */
enum CargoType: string
{
    case GENERAL = 'general';
    case COLD_CHAIN = 'cold_chain';
    case HAZARDOUS = 'hazardous';
    case OVERSIZE = 'oversize';

    public function label(): string
    {
        return match ($this) {
            self::GENERAL => '普货',
            self::COLD_CHAIN => '冷链',
            self::HAZARDOUS => '危险品',
            self::OVERSIZE => '大件',
        };
    }

    /**
     * 判断车辆类型是否匹配货物类型
     */
    public function matchesVehicleType(VehicleType $vehicleType): bool
    {
        return match ($this) {
            self::COLD_CHAIN => $vehicleType === VehicleType::REFRIGERATED,
            self::HAZARDOUS => in_array($vehicleType, [VehicleType::FOUR_POINT_TWO_M, VehicleType::NINE_POINT_SIX_M]),
            self::OVERSIZE => in_array($vehicleType, [VehicleType::THIRTEEN_M, VehicleType::SEVENTEEN_POINT_FIVE_M]),
            default => true,
        };
    }
}
