PHPackages                             jildertmiedema/fill - 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. jildertmiedema/fill

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

jildertmiedema/fill
===================

A helper to fill objects / dto or whatever

v0.2.0(9y ago)014MITPHPPHP ^7.0.0

Since Oct 26Pushed 9y agoCompare

[ Source](https://github.com/jildertmiedema/fill)[ Packagist](https://packagist.org/packages/jildertmiedema/fill)[ RSS](/packages/jildertmiedema-fill/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (3)Used By (0)

Fill
====

[](#fill)

A easy tool to fill objects.

Usage
-----

[](#usage)

A helper function is provided: `mapTo()` will return a callable which can be used in the mapping.

```
    $result = array_map(mapTo(Target::class), $data);
```

Example
-------

[](#example)

```
use function JildertMiedema\Fill\mapTo;

class Demo
{
    private $name;

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

    public function name()
    {
        return $this->name;
    }
}

$data = [
    ['name' => 'test name 1'],
    ['name' => 'test name 1'],
];

$result = array_map(mapTo(Demo::class), $data);

var_dump($result);
```

output:

```
array(2) {
  [0] =>
  class Demo#7 (1) {
    private $name =>
    string(11) "test name 1"
  }
  [1] =>
  class Demo#6 (1) {
    private $name =>
    string(11) "test name 1"
  }
}
```

Customize
---------

[](#customize)

You can customize the behaviour. For example in Laravel you can use the `CallbackNormalizer` to convert snake\_cased\_fields to camelCase.

In this example is shown how to implement your own `mapTo()` function:

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use JildertMiedema\Fill\Build\ReflectionBuilder;
use JildertMiedema\Fill\Fill;
use JildertMiedema\Fill\Normalizer\CallbackNormalizer;
use JildertMiedema\Fill\Normalizer\SimpleNormalizer;

function mapTo($targetClass): \Closure
{
    $normalizer = new CallbackNormalizer(new SimpleNormalizer());
    $normalizer->register(Model::class, function (Model $model) {
        $data = $model->toArray();
        $keys = array_map(function ($key) {
            return Str::camel($key);
        }, array_keys($data));
        $data = array_combine($keys, array_values($data));

        return $data;
    });
    $fill = new Fill(new ReflectionBuilder($targetClass), $normalizer);

    return $fill->map();
}

class DemoModel extends Model
{
    protected $guarded = [];
}

class Target
{
    private $name;
    private $otherValue;

    public function __construct($name, $otherValue)
    {
        $this->name = $name;
        $this->otherValue = $otherValue;
    }

    public function name()
    {
        return $this->name;
    }
}

$data = [
    new DemoModel(['name' => 'test', 'other_value' => 'value']),
];

$result = array_map(mapTo(Target::class), $data);

var_dump($result);
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3534d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17d3aa5c306bcc4739b0953cdc617f1fd05c035f5aff96bef28971ae6603e128?d=identicon)[jildertmiedema](/maintainers/jildertmiedema)

---

Top Contributors

[![jildertmiedema](https://avatars.githubusercontent.com/u/3383186?v=4)](https://github.com/jildertmiedema "jildertmiedema (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jildertmiedema-fill/health.svg)

```
[![Health](https://phpackages.com/badges/jildertmiedema-fill/health.svg)](https://phpackages.com/packages/jildertmiedema-fill)
```

###  Alternatives

[noginn/endurance

PHP library for parsing cycling GPS activities and calculating metrics.

141.2k](/packages/noginn-endurance)

PHPackages © 2026

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