定制 mapado/request-fields-parser 二次开发

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

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

mapado/request-fields-parser

最新稳定版本:v3.1.0

Composer 安装命令:

composer require mapado/request-fields-parser

包简介

Convert string like `id,firstname,lastname,jobs{startDate,position,company{id,recordNumber}}` to the array

README 文档

README

Convert string like id,firstname,lastname,jobs{startDate,position,company{id,recordNumber}} to the following array:

[
    'id' => true,
    'firstname' => true,
    'lastname' => true,
    'jobs' => [
        'startDate' => true,
        'position' => true,
        'company' => [
            'id' => true,
            'recordNumber' => true,
        ],
    ]
]

You can think of it like an explode on steroids.

Also implement a reverseParse function for the opposite transformation.

Installation

composer require mapado/request-fields-parser

Usage

use Mapado\RequestFieldsParser\Parser;

$parser = new Parser();

$outArray = $parser->parse($string);

$outString = $parser->reverseParse($array);

Extensibility

You can decorate the Parser like this:

use Mapado\RequestFieldsParser\ParserInterface;

class ExtendedParser implements ParserInterface
{
    /**
     * @var ParserInterface
     */
    private $decoratedParser;

    public function __construct(ParserInterface $decoratedParser)
    {
        $this->decoratedParser = $decoratedParser;
    }

    public function parse(string $string): array
    {
        // do stuff and return an array
    }
}

Contribute

Just run make test to launch the test suite

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-02-08