PHPackages                             moonspot/builder - 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. moonspot/builder

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

moonspot/builder
================

Base classes for creating Builder classes

v1.1.0(7mo ago)05.6k↓22%BSD-3-ClausePHPPHP ^8.2CI passing

Since Jan 20Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/brianlmoon/builder)[ Packagist](https://packagist.org/packages/moonspot/builder)[ RSS](/packages/moonspot-builder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

Builder
=======

[](#builder)

This library provides a base class for helping implement the Builder Pattern. This is handy for building objects from JSON data being delivered from APIs. It is also handy for converting one class to another.

From [Wikipedia](https://en.wikipedia.org/wiki/Builder_pattern):

The builder pattern is a design pattern that provides a flexible solution to various object creation problems in object-oriented programming. The builder pattern separates the construction of a complex object from its representation.

```
use Moonspot\Builder;
use Example\MyObject;

class MyBuilder extends Builder {

    public function create(array|object $data): object {
        // need an array to work with
        if(is_object($data)) {
            $data = (array)$data;
        }

        $obj = new MyObject();

        // setValue handles nulls and isset issues
        $this->setValue($obj, 'id', $data);

        // setValue can also look for multiple keys
        // If either name or description is set in the data array
        // it will be set to name in the object.
        $this->setValue($obj, 'name', $data, ['description'])
    }
}

$object = MyBuilder::build([
    'id'   => 12345,
    'name' => 'Some name',
]);
```

See Also
--------

[](#see-also)

To make the objects easier to work with, use [Value Objects](https://github.com/brianlmoon/value-objects).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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 ~206 days

Total

4

Last Release

230d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49531?v=4)[Brian Moon](/maintainers/brianlmoon)[@brianlmoon](https://github.com/brianlmoon)

![](https://www.gravatar.com/avatar/243758ed7035943299b60b3927056b7bdefb979d7161183261ddc2ac82a53840?d=identicon)[jkearle](/maintainers/jkearle)

---

Top Contributors

[![brianlmoon](https://avatars.githubusercontent.com/u/49531?v=4)](https://github.com/brianlmoon "brianlmoon (8 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/moonspot-builder/health.svg)

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

###  Alternatives

[schmeits/filament-4-phosphor-icons

This is my package filament-4-phosphor-icons

172.7k](/packages/schmeits-filament-4-phosphor-icons)

PHPackages © 2026

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