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(9mo ago)07.3k↓64%BSD-3-ClausePHPPHP ^8.2CI passing

Since Jan 20Pushed 9mo ago2 watchersCompare

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

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 87% of packages

Maintenance58

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

275d 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

[wordpress/phpdoc-parser

Static code parser for WordPress source.

23920.0k](/packages/wordpress-phpdoc-parser)[webdevstudios/cmb2-user-select

Special CMB2 Field that allows users to define an autocomplete text field for users

211.3k1](/packages/webdevstudios-cmb2-user-select)

PHPackages © 2026

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