shahburhan/payload-struct 问题修复 & 功能扩展

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

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

shahburhan/payload-struct

Composer 安装命令:

composer require shahburhan/payload-struct

包简介

A simple utility to create payloads in an easy object oriented construct

README 文档

README

A simple utility to create payloads in an easy object oriented construct and transform it into different structures viz. array, objects, string(json).

Usage:

Create a new PayloadStruct instance

$payload = new PayloadStruct;

Set Items:

$payload->setName('Jane Doe');
$payload->setEmail('jane@example.com');
$payload->setPhone('1234567890');
$payload->setWebsite('example.com');

You can also chain the setters:

$payload->setName('Jane Doe')
  ->setEmail('jane@example.com')
  ->setPhone('1234567890')
  ->setWebsite('example.com');

Or use assignment notation:

$payload->language = 'English';

And get the final payload in different structures:

$payload->getArray();

Output:

Array
(
    [name] => Jane Doe
    [email] => jane@example.com
    [phone] => 1234567890
    [website] => example.com
    [language] => English
)
$payload->getJson();

Output:

{"name":"Jane Doe","email":"jane@example.com","phone":"1234567890","website":"example.com","language":"English"}
$payload->getObject();

Output:

stdClass Object
(
    [name] => Jane Doe
    [email] => jane@example.com
    [phone] => 1234567890
    [website] => example.com
    [language] => English
)

You can also access individual items with getter notation or direct property access notation as follows:

$payload->getName(); //Outputs Jane Doe
$payload->name; //Outputs Jane Doe

Reset payload data:

$payload->flush();

You can chain on to add new data items:

$payload->flush()
  ->setNewName('John Doe');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固