nekoos-pood/camelcase-arrayobject-mutator 问题修复 & 功能扩展

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

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

nekoos-pood/camelcase-arrayobject-mutator

Composer 安装命令:

composer require nekoos-pood/camelcase-arrayobject-mutator

包简介

Object accessible as array that use keys with camelcase standard

README 文档

README

This is a utility that allows you to use an array-object that ignores key style cases and mutate the keys as camel case style

Install

composer require nekoos-pood/camelcase-arrayobject-mutator

Definition

This entity implements ArrayObject see Documentation

Usage

use NekoOs\Pood\Support\CamelCaseArrayObjectMutator;

Basic use

$thing = new CamelCaseArrayObjectMutator([
  'this is first item with increment key',
  'associative-key' => 'this is item with associative key'
]);

$thing->snake_case   = 'this is item with key using snake case';
$thing['kebab-case'] = 'this is item with key using kebab case';
$thing[]             = 'this is item with key using increment key';

$thing['snake_case']    // return 'this is item with key using snake case'
$thing['kebab-case']    // return 'this is item with key using kebab case'
$thing[0]               // return 'this is first item with increment key'
$thing[1]               // return 'this is item with key using increment key'
$thing['kebab-case']    // return 'this is item with key using kebab case'
$thing['snakeCase']     // return 'this is item with key using snake case'
$thing['kebabCase']     // return 'this is item with key using kebab case'
$thing->snake_case      // return 'this is item with key using snake case'
$thing->snakeCase       // return 'this is item with key using snake case'
$thing->kebabCase       // return 'this is item with key using kebab case'
$thing->undefined       // throw error 'Undefined property: NekoOs\Pood\Support\CamelCaseArrayObjectMutator::$undefined'

get_object_vars($thing) // return array (
                         //   'associativeKey' => 'this is item with associative key',
                         //   'snakeCase'      => 'this is item with key using snake case',
                         //   'kebabCase'      => 'this is item with key using kebab case',
                         // )

The object ignores the case styles of the keys

$thing->snakeCase    = 'replace value with key using snake case'
$thing['kebabCase']  = 'replace value with key using kebab case'

$thing['snake_case']    // return 'replace value with key using snake case'
$thing['kebab-case']    // return 'replace value with key using kebab case'
$thing['snakeCase']     // return 'replace value with key using snake case'
$thing['kebabCase']     // return 'replace value with key using kebab case'
$thing->snake_case      // return 'replace value with key using snake case'
$thing->snakeCase       // return 'replace value with key using snake case'
$thing->kebabCase       // return 'replace value with key using kebab case'

How to get the values with original indexes?

$thing->getStorage()

Custom use

// change behavior from instance as object common without mutation of keys
$thing->behavior(CamelCaseArrayObjectMutator::PREFER_ORIGINAL_KEYS);

get_object_vars($thing) // return array (
                         //   'associative-key' => 'this is item with associative key',
                         //   'snake_case'      => 'this is item with key using snake case',
                         //   'kebab-case'      => 'this is item with key using kebab case',
                         // )

Global configuration

// change behavior by default as object common without mutation of keys
CamelCaseArrayObjectMutator::defaultBehavior(CamelCaseArrayObjectMutator::PREFER_ORIGINAL_KEYS);

// Enabled throw errors by default on undefined fields
CamelCaseArrayObjectMutator::defaultBehavior(CamelCaseArrayObjectMutator::DEBUG_ON_UNDEFINDED);
// Disabled throw errors by default on undefined fields
CamelCaseArrayObjectMutator::defaultBehavior(~CamelCaseArrayObjectMutator::DEBUG_ON_UNDEFINDED);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固