chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
 * API入参静态检查类
 * 可以对API的参数类型、长度、最大值等进行校验
 *
 **/
class NuomiRequestParamsCheck
{
     /**
      * [checkNotNull description]
      * @param  [type] $value     [description]
      * @param  [type] $fieldName [description]
      * @return [type]            [description]
      */
    public static function checkNotNull($fieldName,$value) {
        if(self::checkEmpty($value)){
            throw new Exception("missing param: " .$fieldName , 1);
        }
    }
 
    /**
     * @param $value
     * @return bool
     */
    public static function checkEmpty($value)
    {
        if (!isset($value)) {
            return true;
        }
        if ($value === null) {
            return true;
        }
        if (trim($value) === "") {
            return true;
        }
        return false;
    }
}