承接 vistik/type-hinted-arrays 相关项目开发

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

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

vistik/type-hinted-arrays

最新稳定版本:v2.0.0

Composer 安装命令:

composer require vistik/type-hinted-arrays

包简介

A simple way to create typed collections in PHP - build on Illuminate\Support\Collection

README 文档

README

Build Status

What is this?

This is a very simple way to make arrays type hinted!

$list = new UserCollection(new User());

OK

$list = new UserCollection('User');

Will throw:

Vistik\Exception\InvalidTypeException: Item (string) 'User' is not a Vistik\Example\User object!

Install

Run composer require vistik/type-hinted-arrays

Use build in Collections for primitives

Out-of-the-box collections for:

  • Booleans
  • Integers
  • Floats
  • Strings
  • Emails
  • Numbers (float or int)

Do I have to create a type for each list? Yes, but

Look how easy it is:

class UserCollection extends TypedCollection{
    protected $type = 'Vistik\Example\User';
}

2 simple steps

  1. Create a Class eg. AccountCollection extend TypedCollection
  2. Just replace protected $type = 'Vistik\Example\User'; with your class

or

If the check is more then just a is_a check, you can overwrite the function: isValidItem($item) in your new Collection class

Features

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-02-20