DeviceStatus.php 648 Bytes
<?php

namespace domain\device;


class DeviceStatus
{
    const NO_AUTH = 0; //未授权,
    const HAS_AUTH = 1; //已授权,
    const FAIL_AUTH = 2;  //授权失败

    /**
     * @param string $index
     * @return array|string
     */
    static function statusLabels($index = '')
    {
        $arr = [
            self::NO_AUTH => '未授权',
            self::HAS_AUTH => '已授权',
            self::FAIL_AUTH => '授权失败',
        ];
        if ('' === $index) {
            return $arr;
        }

        if (isset($arr[$index])) {
            return $arr[$index];
        } else {
            return '';
        }
    }
}