承接 matthiasmullie/types 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

matthiasmullie/types

最新稳定版本:1.0.2

Composer 安装命令:

composer require matthiasmullie/types

包简介

Some convenient classes to describe/cast types of values

关键字:

README 文档

README

Build status Code coverage Latest version Downloads total License

Installation

Simply add a dependency on matthiasmullie/types to your composer.json file if you use Composer to manage the dependencies of your project:

composer require matthiasmullie/types

Usage

use MatthiasMullie\Types;

$type = new Types\Json(
    new Types\Map([
        'user_id' => new Types\Sha1(
            description: 'Unique user id',
        ),
        'email' => new Types\Email(
            description: 'Email address of the user',
        ),
        'gender' => new Types\Enum(
            ['m', 'f'],
            description: 'Biological sex',
        ),
        'birthdate' => new Types\Optional(
            new Types\Integer(),
            description: 'Birth date, UNIX timestamp',
        ),
    ]),
);
// this will succeed because the input is valid;
// `birthdate`, given as a string, will be cast to an integer
$safeInput = $type([
    'user_id' => 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd4',
    'email' => 'jane.doe@example',
    'gender' => 'f',
    'birthdate' => '1715950172',
]);
// this will throw an exception because a required field (`gender`)
// is missing; note: `$type->test(...)` can also be used to simply
// check validity instead
$safeInput = $type([
    'user_id' => 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd4',
    'email' => 'jane.doe@example',
    'birthdate' => '1715950172',
]);
// this will throw an exception because the input for `email` is not
// a valid email address
$safeInput = $type([
    'user_id' => 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd4',
    'email' => 'not an email address',
    'gender' => 'f',
    'birthdate' => '1715950172',
]);

License

types is MIT licensed.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固