定制 ocolin/global-type 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ocolin/global-type

最新稳定版本:1.6

Composer 安装命令:

composer require ocolin/global-type

包简介

Simple library for making sure global variables are of a specific type

README 文档

README

Description

A simple utility for getting values from Global variables as a specific type. Rather than having to type check them when you know what type to expect, this can ensure those globals are of the right type.

Globals supported

  • $_ENV
  • $_POST
  • $_GET
  • $_REQUEST
  • $_SESSION
  • $_SERVER
  • $_REQUEST
  • $_FILES
  • $_COOKIES
  • $GLOBALS

Types supported

  • string
  • int
  • float
  • array
  • object
  • bool

Format

Functions are all static and come in two modes. One for returning a type even if the input is the wrong type, and one for returning null if the type is wrong.

GET - Examples

$output = Ocolin\GlobalType\GT::getSring( name: 'value' );
$output = Ocolin\GlobalType\GT::getSringNull( name: 'value' );
$output = Ocolin\GlobalType\GT::getInt( name: 'value' );
$output = Ocolin\GlobalType\GT::getIntNull( name: 'value' );
$output = Ocolin\GlobalType\GT::getFloat( name: 'value' );
$output = Ocolin\GlobalType\GT::getFloatNull( name: 'value' );
$output = Ocolin\GlobalType\GT::getArray( name: 'value' );
$output = Ocolin\GlobalType\GT::getArrayNull( name: 'value' );
$output = Ocolin\GlobalType\GT::getObject( name: 'value' );
$output = Ocolin\GlobalType\GT::getObjectNull( name: 'value' );
$output = Ocolin\GlobalType\GT::getBool( name: 'value' );
$output = Ocolin\GlobalType\GT::getBoolNull( name: 'value' );

The input parameter is always the name of the global variable. The type of global will be the name of the global type in lowercase as the prefix of the function name.

$output = Ocolin\GlobalType\GT::{global name}{type}{null}( name: '{var name}');

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-22