承接 renoki-co/laravel-explicit-array 相关项目开发

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

邮箱: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
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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