定制 hxss/array-object 二次开发

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

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

hxss/array-object

Composer 安装命令:

composer require hxss/array-object

包简介

README 文档

README

The OOP interface for PHP array.

The class realize almost all php functions.

Basic principles of work:

  • All php functions with array_ prefix are now class methods without the prefix in camel case(array_change_key_case -> ArrayObject::changeKeyCase());
  • Class methods do not require array type arg in most cases;
  • All methods that accepted array args now accepts array|ArrayObject;
  • All methods that had to return array now returns ArrayObject;

Exceptions and differences with php api:

Not realized functions:

Functions with changed API:

  • ArrayObject::combine() - static method;
  • array_fill & array_fill_keys are merged into static ArrayObject::fill() where second argument defines behavior;
  • ArrayObject::range() - static method;
  • All array_diff* functions merged into ArrayObject::diff() where userfunc always gets 4 args(key1, val1, key2, val2);
  • ArrayObject::filter() always pass 2 args into userfunc: key and val;
  • All array_​intersect* functions merged into ArrayObject::intersect() where userfunc always gets 4 args(key1, val1, key2, val2);
  • array_​key_​first realized as ArrayObject::firstKey();
  • array_​key_​last realized as ArrayObject::lastKey();
  • All array_​merge* functions merged into ArrayObject::merge() method;
  • ArrayObject::multisort() saves sorted arrays only in passed ArrayObject values. All array-type args will used in sorting as usual but wouldn't updated.
  • array_​rand realized as ArrayObject::randKeys();
  • array_replace & array_​replace_​recursive are merged into static ArrayObject::replace() where last optional argument true means recursion;
  • All array sort functions merged into ArrayObject::sort() with 3 new flags that can be combined with default flags(bitwise OR);
  • array_walk & array_walk_​recursive are merged into static ArrayObject::walk() where last optional argument true means recursion;

New features:

  • ArrayObject::recursive() - recursively convert all sub-array in ArrayObject;
  • ArrayObject::items() - returns original array;
  • ArrayObject::append() - append one or more elements onto the end of array. Like push but returns self;
  • ArrayObject::prepend() - Prepend one or more elements to the beginning of an array. Like unshift but returns self;
  • ArrayObject::rand() - returns associated array with one or more random items of an array;
  • ArrayObject::first() - returns first value of the array;
  • ArrayObject::last() - returns last value of the array;
  • ArrayObject::eq() - checks if the object equal to $other array;
  • ArrayObject::touch() - returns the value at specified offset or init it with $default value;
  • ArrayObject::generator() - generates new array by user generator;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固