jerodev/data-mapper 问题修复 & 功能扩展

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

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

jerodev/data-mapper

最新稳定版本:1.2.1

Composer 安装命令:

composer require jerodev/data-mapper

包简介

Maps raw data to a typed PHP object

README 文档

README

run-tests Latest Stable Version

This package will map any raw data into a predefined strong-typed PHP object.

Installation

The mapper has no external dependencies apart from PHP8.1 or higher. It can be installed using composer:

composer require jerodev/data-mapper

Basic mapping

Let's start with the basics. The mapper will map data directly to public properties on objects. If these properties have types defined either using types introduced in PHP7.4 or through PHPDoc, the mapper will attempt to cast the data to these types.

For example: imagine having an Entity class with the public properties $id and $name:

class User { public int $id; public string $name; }

To map data from an array we simply pass the class name and an array with data to the mapper.

$mapper = new \Jerodev\DataMapper\Mapper(); $entity = $mapper->map(User::class, [ 'id' => '5', 'name' => 'John Doe', ]); // User { // +id: 5, // +name: "John Doe", // }

This is a simple example, but the mapper can also map nested objects, arrays of objects, keyed arrays, and even multi-level arrays.

Documentation

More information about mapping, configuration and best practices can be found in the documentation.

License

This library is licensed under the MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04