过滤
@param $array
@return mixed
5134
public function filter(&$array) {
        while(list($key, $var) = each($array)) {
            if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || '' . intval($key) == "$key")) {
                if (is_string($var)) {
                    $array[$key] = stripslashes($var);
                }
                if (is_array($var))  {
                    $array[$key] = $this->filter($var);
                }
            }
        }
        return $array;
    }
779148
protected function implode( $array )
    {
        $retString = '';
        if ( empty( $array ) )
        {
            return '';
        }
        foreach ( $array as $key => $value )
        {
            if ( is_array( $value ) )
            {
                $value = $this->implode( $value );
            }
            $retString .= $key . ' ' . $value . ' ';
        }

        return $retString;
    }
478537
public function arrstr(array $array) {
        $array = array_map(function($value) {
            return pg_escape_identifier((string) $value);
        }, $array);
        return $this->str(sprintf('{%s}', implode(',', $array)));
    }
1234391
private static function dumpArray(array $array) {
    $str = "[";
    foreach ($array as $value) {
      if (is_object($value)) {
        $str .= $value->__toString().", ";
      }
      else {
        $str .= $value.", ";
      }
    }
    $str = preg_replace("/, $/", "", $str)."]";
    return $str;
  }
1332096
public static function get(array $array, ...$keys)
    {
        $key = array_shift($keys);

        if (!isset($array[$key])) {
            return null;
        }

        if (empty($keys)) {
            return $array[$key] ?? null;
        }

        if (!\is_array($array[$key])) {
            return null;
        }

        return self::get($array[$key], ...$keys);
    }
1179318
public function regex($array = [])
    {
        $filtered = [];
        foreach ($array as $key => $value) {
            if ($this->isRegex($key)) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
326497
protected function arrayToObject(array $array)
    {
        $obj = (object) [];

        foreach ($array as $k => $v) {

            if (strlen($k)) {
                if (is_array($v)) {
                    $obj->{$k} = $this->arrayToObject($v);
                } else {
                    $obj->{$k} = $v;
                }
            }
        }

        return $obj;
    }
113533
public function arrayChangeCaseKey($array)
    {
        return array_map(function ($item) {
            if (is_array($item)) {
                $item = $this->arrayChangeCaseKey($item);
            }

            return $item;
        }, array_change_key_case($array));
    }
1100568
public static function flatten($array)
    {
        $return = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $return = \array_merge($return, static::flatten($value));
            } elseif ($value instanceof Collection) {
                $return = \array_merge($return, static::flatten($value->all()));
            } else {
                $return[$key] = $value;
            }
        }

        return $return;
    }
1161
public function checkAuthArray($array)
	{

		//root
		if(array_has($array, 'root')){
			if(array_get($array, 'root') != 'only') {
				die('FooWeChat\Authorize\Auth\checkAuthArray: 参数 root 值错误');
			}
		}

		//admin
		if(array_has($array, 'admin')){
			$a = array_get($array, 'admin');
			if($a != 'yes' && $a != 'no' && $a != 'only') {
				die('FooWeChat\Authorize\Auth\checkAuthArray: 参数 admin 值错误');
			}
		}

		//way
		if(array_has($array, 'way')){
			$a = array_get($array, 'way');
			if($a != 'wechat' && $a != 'web' && $a != 'all') {
				die('FooWeChat\Authorize\Auth\checkAuthArray: 参数 way 值错误');
			}
		}

		//except
		if(array_has($array, 'except')){
			$this->checkUser(array_get($array, 'except'));
		}

		//user
		if(array_has($array, 'user')){
			$this->checkUser(array_get($array, 'user'));
		}

	}
1040187
public function fromArray($array) {
		$array=parent::fromArray($array);
		foreach ( $array as $key => $value ) {
			$this->setProperty($key, $value);
		}
		return $array;
	}
934334
public function getArrayLevel($array)
	{
		$n=1;
		foreach ($array as $item) {
			if(is_array($item)){
				$n=$this->getArrayLevel($item)+1;
			}
		}
		return $n;

	}
70213
private function getArray(Array_ $array)
    {
        $return = [];

        foreach ($array->items as $item) {
            if ($item->key === null) {
                $return[] = $this->getValue($item->value);
            } else {
                $return[$this->getValue($item->key)] = $this->getValue($item->value);
            }
        }

        return $return;
    }
211987
static function array2str($array)
    {
        $str = '';
        foreach ($array as $li)
        {
            $str .= self::build_line($li) . self::$row_sep;
        }
        return $str;
    }
244404
public static function productOfArray($array)
    {
        $res = $array[0];

        for ($i = 1; $i < count($array); $i++) {
            $res = $res * $array[$i];
        }

        return $res;
    }
294158
public function auth($array)
	{
		$this->checkAuthArray($array);

		//root
		if($this->isRoot()){
			return true;
			
		}else{
			if(array_has($array, 'root') || array_get($array, 'root') === 'only'){
				return false;

			}
		}


		//admin
		if(!$this->isRoot() && $this->isAdmin()){
			if(!array_has($array, 'admin') || array_get($array, 'admin') === 'yes' || array_get($array, 'admin') === 'only'){
				return true;
				
			}
		}

		//如果为外部: 客户, 供应商, 政务部门
		if(!$this->isInside()) return false;


		//常规
		if(!$this->isRoot() && !$this->isAdmin()){
			if(array_has($array, 'admin') && array_get($array, 'admin') === 'only'){
				return false;
				
			}
		}

		// 访问方法
		if(array_has($array, 'way')){
			$way = array_get($array, 'way');

			if($way === 'wechat'){
				if(!$this->usingWechat()){
					return false;
					
				}
			}elseif($way === 'web'){
				if($this->usingWechat()){
					return false;
					
				}
			}
		}

		//在禁止名单中
		if(array_has($array, 'except')){
			$str = array_get($array, 'except');
			$work_id_or_name_list = explode('|', $str);

			if(array_search($this->self->work_id, $work_id_or_name_list) === false && array_search($this->self->name, $work_id_or_name_list) === false){
				//go on..
			}else{

				return false;
				
			}
		}

		//在允许名单中
		if(array_has($array, 'user')){
			$str = array_get($array, 'user');
			$work_id_or_name_list = explode('|', $str);
			if(array_search($this->self->work_id, $work_id_or_name_list) === false && array_search($this->self->name, $work_id_or_name_list) === false){
				//go on
			}else{
				return true;
				
			}
		}

		//职位 order
		if(array_has($array, 'position')){
			$str = array_get($array, 'position');
			$positions = explode('|', $str);
			$me = $this->self->position;
			$my_position_order = Position::find($me)->order;
			if(!count($my_position_order)) die('FooWeChat\Authorize\Auth: need login');

			foreach ($positions as $p){

				if(str_contains($p, '>') && !str_contains($p, '=')) {
					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					$rec = Position::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.position1: 职位名错误');
					if($my_position_order >= $rec->order){
						return false;
						
					}else{
						//return true;
						//go on ..
					}

				}elseif (str_contains($p, '>=')){
					$name = mb_substr($p, 2, mb_strlen($p),'utf-8');
					$rec = Position::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.position2: 职位名错误');
					if($my_position_order > $rec->order){
						return false;
						
					}else{
						//return true;
						//go on..
					}

				}elseif (str_contains($p, '=') && !str_contains($p, '>=') && !str_contains($p, '<=')){

					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					$rec = Position::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.position3: 职位名错误');
					if($my_position_order <> $rec->order){
						return false;
						
					}else{
						//return true;
						//go on..
					}

				}elseif (str_contains($p, '<=')) {

					$name = mb_substr($p, 2, mb_strlen($p),'utf-8');
					$rec = Position::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.position4: 职位名错误');
					if($my_position_order < $rec->order){
						return false;
						
					}else{
						//return true;
						//go on..
					}

				}elseif (str_contains($p, '<') && !str_contains($p, '=')) {

					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					$rec = Position::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.position5: 职位名错误');
					if($my_position_order <= $rec->order){
						return false;
						
					}else{
						//return true;
						//go on..
					}
				}
				
			}

		}

		//department
		if(array_has($array, 'department')){

			$str = array_get($array, 'department');
			$departments = explode('|', $str);

			$me = $this->self->department;
			//echo $me;

			$my_department_code = Department::find($me)->code;
			//echo $my_department_code;
			if(!count($my_department_code)) die('FooWeChat\Authorize\Auth: need login');
			foreach ($departments as $p){
				if(str_contains($p, '>') && !str_contains($p, '=')) {

					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					//echo $name;
					$rec = Department::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.department1: 部门名错误');
					$needDepartment = $rec->code;
					//echo $my_department_code.'*'.$needDepartment;
					if(str_contains($my_department_code, $needDepartment) || 
						($my_department_code != $needDepartment && 
						!str_contains($needDepartment, $my_department_code))
						){
						return false;
						
					}else{
						//return true;
						//go on..
					}
					
				}elseif(str_contains($p, '>=')) {
					$name = mb_substr($p, 2, mb_strlen($p),'utf-8');
					//echo $name;
					$rec = Department::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.department2: 部门名错误');
					//echo $my_department_code.'/'.$rec->code;
					$needDepartment = $rec->code;
					if(($my_department_code != $needDepartment && 
						!str_contains($needDepartment, $my_department_code))
						){
						return false;
						
					}else{
						//return true;
						//go on..
					}
				}elseif (str_contains($p, '=') && !str_contains($p, '>=') && !str_contains($p, '<=')){
					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					//echo $name;
					$rec = Department::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.department3: 部门名错误');
					//echo $my_department_code.'/'.$rec->code;
					$needDepartment = $rec->code;
					if($my_department_code != $needDepartment){
						return false;
						
					}else{
						//return true;
						//go on..
					}
				}elseif (str_contains($p, '<=')){
					$name = mb_substr($p, 2, mb_strlen($p),'utf-8');
					//echo $name;
					$rec = Department::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.department4: 部门名错误');
					//echo $my_department_code.'/'.$rec->code;
					$needDepartment = $rec->code;
					if(($my_department_code != $needDepartment && 
						!str_contains($my_department_code, $needDepartment))
						){
						return false;
						
					}else{
						//return true;
						//go on..
					}
				}elseif (str_contains($p, '<') && !str_contains($p, '=')) {
					$name = mb_substr($p, 1, mb_strlen($p),'utf-8');
					//echo $name;
					$rec = Department::where('name', $name)->first();
					if(!count($rec)) die('FooWeChat\Authorize\Auth.department5: 部门名错误');
					
					$needDepartment = $rec->code;
					//echo $my_department_code.'/'.$rec->code;
					if($my_department_code === $needDepartment || ($my_department_code != $needDepartment && 
						!str_contains($my_department_code, $needDepartment))
						){
						return false;
						
					}else{
						//return true;
						//go on..
					}
				}
			}

		}
		return true;

	}
966523
public static function keyToCamel($array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[Strings::case2camel($key)] = self::keyToCamel($value);
            } else {
                $result[Strings::case2camel($key)] = $value;
            }
        }
        return $result;
    }