danack/convert 问题修复 & 功能扩展

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

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

danack/convert

Composer 安装命令:

composer require danack/convert

包简介

Converts between objects and scalars trivially.

README 文档

README

A lightweight library for making it easier to convert objects to and from arrays, and to and from Json.

Actions Status

Design goals

The library was designed to make it as simple as possible to make your data be convertible to Json for simple cases, and then be easy to customise how the objects are converted for more advanced cases.

Example

After adding the Convert\ToJson trait to an object, you can call toJson to convert the object to Json.

<?php

$article = new Article(
    1,
    "Example",
    "This is an example of how to make an object convertible to Json."
);

echo $article->toJson();

// Output is:
// {"id":1,"title":"Example","text":"This is an example of how to make an object convertible to Json."}

After adding the Convert\FromJson trait to a class, you can call fromJson statically, to create an instance.

<?php

$json = '{"id":1,"title":"Example","text":"This is an example of how to make an object convertible to Json."}';

$article = Article::fromJson($json);

echo "Id is: " . $article->getId() . "\n";
echo "Title is: " . $article->getTitle() . "\n";

// output is:
// Id is: 1
// Title is: Example

Installation

composer require danack/convert

Tests

We have several tools that are run to improve code quality. Please run sh runTests.sh to run them all locally, or sh runTestsInContainer.sh to run them in a container.

Pull requests should have full unit test coverage.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固