承接 vicary/object-path 相关项目开发

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

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

vicary/object-path

Composer 安装命令:

composer require vicary/object-path

包简介

Fork of peridot-php/object-path. A string syntax to fetch values from array and object hierarchies

README 文档

README

Allows traversal of objects and arrays with a simple string syntax. Extracted from Peridot's matcher library: Leo.

Usage

use Peridot\ObjectPath\ObjectPath;

// Works with nested arrays, objects, or a mixture of both.
$data = [
  'name' => 'Brian',
  'hobbies' => [
    'reading',
    'programming',
    'lion taming'
  ],
  'address' => new stdClass()
  [
    'street' => '1234 Lane',
    'zip' => '12345'
  ]
];

$data['address']->street = '1234 Lane';
$data['address']->zip = 12345;

// Wraps the value with ObjectPath
$path = new ObjectPath($data);

// Get the value directly
$reading = $path->{'hobbies[0]'};
$zip = $path->{'address[zip]'};

// Sets the value
$path->{'address->street'} = '12345 Street';

// Removes the property
unset($path->{'hobbies[2]'});



// backward compatible with peridot-php/object-path
$reading = $path->get('hobbies[0]');
$zip = $path->get('address[zip]');

// the result of get() is an ObjectPathValue instance
$value = $reading->getPropertyValue();

Tests

$ composer install
$ vendor/bin/peridot specs/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固