PHPackages                             kozz/class-mapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kozz/class-mapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kozz/class-mapper
=================

Class Mapper

05.1kPHP

Since Nov 3Pushed 11y ago1 watchersCompare

[ Source](https://github.com/urakozz/php-class-mapper)[ Packagist](https://packagist.org/packages/kozz/class-mapper)[ RSS](/packages/kozz-class-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Class mapper
============

[](#class-mapper)

[![Build Status](https://camo.githubusercontent.com/41a051d26fa744e30f50975276c50036fbb097a0cab0a24cba3996ab24656b00/68747470733a2f2f7472617669732d63692e6f72672f7572616b6f7a7a2f7068702d636c6173732d6d61707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/urakozz/php-class-mapper)[![Coverage Status](https://camo.githubusercontent.com/b5b3b2929475e8e67b097edbb654027a1a3eba4b7d16583392b51642bc9f45f7/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7572616b6f7a7a2f7068702d636c6173732d6d61707065722f62616467652e706e67)](https://coveralls.io/r/urakozz/php-class-mapper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c2fa3611f54561c42d1e854f1d4ca905168b7274b54d0afffe01c3f6c8f1a413/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7572616b6f7a7a2f7068702d636c6173732d6d61707065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/urakozz/php-class-mapper/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/fa90f785ae2f93ba932b34923e80cedcdceb8f176a4b6e46b36d17618802d9eb/68747470733a2f2f706f7365722e707567782e6f72672f6b6f7a7a2f636c6173732d6d61707065722f762f737461626c652e737667)](https://packagist.org/packages/kozz/class-mapper)[![Latest Unstable Version](https://camo.githubusercontent.com/a8003cf93db8a26e26e9b1fc140314f9744510f9e57dea4c0d47340053b4d3d3/68747470733a2f2f706f7365722e707567782e6f72672f6b6f7a7a2f636c6173732d6d61707065722f762f756e737461626c652e737667)](https://packagist.org/packages/kozz/class-mapper)[![License](https://camo.githubusercontent.com/f520a262b7d2eae3e3d6fa2ceda2fe7c198b087e68139eb402f0016e5e267117/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b6f7a7a2f636c6173732d6d61707065722e737667)](https://packagist.org/packages/kozz/class-mapper)

Mapping Class properties using JMS Serializer components

### Why to use it

[](#why-to-use-it)

ClassMapper can only fill simple maps and Normalizer performs type casting. So it works much faster than original JMS Serializer.

### Usage

[](#usage)

Create a Map class like this

```
use JMS\Serializer\Annotation\Type;
class Map
{
  /**
   * @Type("integer")
   */
  public $client_id;
  /**
   * @Type("integer")
   */
  public $sender_id;
  /**
   * @Type("string")
   */
  public $order_requisite;
  /**
   * @Type("string")
   */
  public $order_warehouse;
}
```

### Using ClassMapper

[](#using-classmapper)

Now let's map it

```
use Kozz\Components\ClassMapper\ClassMapper;

$map = new Map();
$mapper = new ClassMapper($map);
$mapper->setAttributes([
  'client_id'=>1,
  'sender_id'=>2,
  'order_requisite'=>3,
  'order_warehouse'=>4,
]);

$map->order_id; // 1 (integer)
$map->sender_id; // 2 (integer)
$map->order_requisite; // 3 (integer)
$map->order_warehouse; // 4 (integer)
```

### Using ClassMapper and Normalizer

[](#using-classmapper-and-normalizer)

`Normalizer` is decorator for `ClassMapper`. It reads `@Type` annotations and performs type casting

```
use Kozz\Components\ClassMapper\ClassMapper;
use Kozz\Components\ClassMapper\Normalizer;

$map = new Map();
$mapper = new Normalizer(new ClassMapper($map));
$mapper->setAttributes([
  'client_id'=>'1str',
  'sender_id'=>'2str',
  'order_requisite'=>'3str',
  'order_warehouse'=>'4str',
]);

$map->order_id; // 1 (integer)
$map->sender_id; // 2 (integer)
$map->order_requisite; // '3str' (string)
$map->order_warehouse; // '4str' (string)
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f78e5a1e5128b31ba7dfedcc9a3ccfbc4852f5df1b79a54867aa377169968a1?d=identicon)[urakozz](/maintainers/urakozz)

---

Top Contributors

[![urakozz](https://avatars.githubusercontent.com/u/5797393?v=4)](https://github.com/urakozz "urakozz (3 commits)")

### Embed Badge

![Health badge](/badges/kozz-class-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/kozz-class-mapper/health.svg)](https://phpackages.com/packages/kozz-class-mapper)
```

###  Alternatives

[phpu/calendar

中国日历，通过天文计算和民间推算方法，准确计算出公历-1000年至3000年的农历、干支、节气等，同时支持多配置、多语言、多时区。

201.7k](/packages/phpu-calendar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
