UpgradeStatus.php 2.3 KB
<?php

namespace domain\upgrade;

/**
 * 版本发布状态
 * Class UpgradeStatus
 * @package domain\upgrade
 */
class UpgradeStatus
{
    /**
     * 发布状态
     */
    const STATUS_ON     = 1; // 已发布
    const STATUS_WAIT   = 0; // 未发布

    /**
     * 是否强制升级
     */
    const FOCUSE_NO    = 1; // 不强制升级
    const FOCUSE_YES   = 2; // 强制升级

    /**
     * 版本类型
     */
    const TYPE_APP    = 1; // app类升级
    const TYPE_OTA   = 2; // OTA整包升级

    /**
     * 升级类型
     */
    const PACKAGE_TYPE_ALL    = 1; // 全量升级
    const PACKAGE_TYPE_PART   = 2; // 增量升级

    /**
     * 同步OSS状态
     */
    const OSS_UPLOAD_WAIT     = 1;  // 等待同步OSS
    const OSS_UPLOAD_SUCCESS  = 2;  // 同步OSS成功

    /**
     * @return array
     */
    public static function statusLabels()
    {
        return [
            self::STATUS_WAIT   => '未发布',
            self::STATUS_ON    => '已发布',
        ];
    }

    /**
     * @param string $status
     * @return mixed|string
     */
    public static function statusLabel($status = null)
    {
        $statusLabels = self::statusLabels();
        return isset($statusLabels[$status]) ? $statusLabels[$status] : '';
    }

    /**
     * @return array
     */
    public static function focuseLabels()
    {
        return [
            self::FOCUSE_NO    => '正常升级',
            self::FOCUSE_YES   => '强制升级'
        ];
    }

    /**
     * @param string $status
     * @return mixed|string
     */
    public static function focuseLabel($status = null)
    {
        $focuseLabels = self::focuseLabels();
        return isset($focuseLabels[$status]) ? $focuseLabels[$status] : '';
    }

    /**
     * 获取所有的升级类型
     * @return array
     */
    public static function packageTypeLabels()
    {
        return [
            self::PACKAGE_TYPE_ALL    => '全量升级',
            self::PACKAGE_TYPE_PART   => '增量升级'
        ];
    }

    /**
     * 获取指定的升级类型
     * @param string $type
     * @return mixed|string
     */
    public static function packageTypeLabel($type = null)
    {
        $packageTypeLabels = self::packageTypeLabels();
        return isset($packageTypeLabels[$type]) ? $packageTypeLabels[$type] : '';
    }
}