nitier/datatype 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

nitier/datatype

最新稳定版本:0.1.0

Composer 安装命令:

composer require nitier/datatype

包简介

Data type helpers

README 文档

README

A PHP library for handling various data types with built-in validation for format, range, and nullability.

📦 Installation

Requires PHP 8.0+. Install the package via Composer:

composer require nitier/datatype

🛠 Supported Data Types

  • Text Types: TextType, VarcharType, TinyTextType, MediumTextType, LongTextType
  • Temporal Types: DateType, TimeType, DatetimeType, TimestampType, YearType
  • Numeric Types: IntType, FloatType, DecimalType, TinyIntType, MediumIntType, SmallIntType

🚀 Usage Examples

Text Types

VarcharType

use Nitier\DataType\Type\VarcharType;

$varchar = new VarcharType(length: 100);
$varchar->setValue('Example text');
echo $varchar->getValue(); // Output: Example text

try {
    $varchar->setValue(str_repeat('A', 101)); 
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage(); // Error: length exceeded
}

Temporal Types

DateType

use Nitier\DataType\Type\DateType;

$date = new DateType();
$date->setValue('2023-11-28');
echo $date->getValue(); // Output: 2023-11-28

try {
    $date->setValue('28.11.2023');
} catch (\InvalidArgumentException $e) {
    echo $e->getMessage(); // Error: invalid format
}

📂 Project Structure

DataType/
├── src/
│   └── Type/
│       ├── TextType.php
│       ├── VarcharType.php
│       ├── DateType.php
│       ├── DatetimeType.php
│       └── ...
├── tests/
└── composer.json

🧪 Running Tests

Ensure PHPUnit is installed:

composer require --dev phpunit/phpunit

Run tests:

composer test

📝 License

Licensed under the MIT License. See LICENSE for details.

🤝 Contributions

Contributions are welcome via pull requests or issues. Let's make this library better together!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-27