renoki-co/laravel-explicit-array 问题修复 & 功能扩展

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

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

renoki-co/laravel-explicit-array

最新稳定版本:1.0.0

Composer 安装命令:

composer require renoki-co/laravel-explicit-array

包简介

Improved Laravel dot notation for explicit array keys.

README 文档

README

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Improved Laravel dot notation for explicit array keys.

🚀 Installation

You can install the package via composer:

composer require renoki-co/laravel-explicit-array

🙌 Usage

The original Laravel's Arr::set() method treats the dots within the key as separators for nested values. This is expected. The segments will create a nested value some -> annotation -> com/ttl with a value of 1800.

$annotations = [
    'some.annotation.com/ttl' => 900,
];

Arr::set($annotations, 'some.annotation.com/ttl', 1800);

// Current result
// [
//     'some' => [
//         'annotation' => [
//             'com/ttl' => 1800
//         ]
//     ]
// ]

// Desired result
// [
//     'some.annotation.com/ttl' => 1800
// ]

To fix this, Explicit Array introduces a new RenokiCo\ExplicitArray\Arr class, which altered the ::set() method, so that will make sure to read the segments between quotes as literal keys.

You may use this class as your regular Arr class because it extends the original \Illuminate\Support\Arr class.

use RenokiCo\ExplicitArray\Arr;

Arr::set($annotations, '"some.annotation.com/ttl"', 1800);

// [
//     'some.annotation.com/ttl' => 1800
// ]

This can work with mixed segments, meaning that as long as you keep the dots outside the quotes, you can specify nested values:

use RenokiCo\ExplicitArray\Arr;

Arr::set($annotations, 'annotations.nested."some.annotation.com/ttl"', 1800);

// [
//     'annotations' => [
//         'nested' => [
//             'some.annotation.com/ttl' => 1800
//         ]
//     ]
// ]

🐛 Testing

vendor/bin/phpunit

🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.

🎉 Credits

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-10-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固