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

ActiveLibrary

amtgard/builder-traits
======================

Builder traits

v2.2.2(4mo ago)0333MITPHPPHP &gt;=8.1

Since Dec 3Pushed 4mo agoCompare

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

READMEChangelog (9)DependenciesVersions (14)Used By (3)

Builder Trait
=============

[](#builder-trait)

Implements a Lombokish version of Builder using Traits.

Supports the following traits individually:

- Builderå
- Getter
- Setter
- ToBuilder
- Data

Example usage is in `tests/Models/` and `tests/BuilderTest.php`.

### Builder

[](#builder)

To add builder functionality, add the Builder trait:

```
use Builder;
```

You can then construct an object using the builder fluent interface:

```
Gato::builder()->age(7)->name("Charlie")->build();
```

### Getter, Setter, Data

[](#getter-setter-data)

You can add getters and setters over all private members by adding the Getter or Setter traits.

Due to limitations in library design, both Getter and Setter cannot be used in the same class.

Instead, use the Data trait.

#### Getter

[](#getter)

```
class Gato {
    use Getter;
    private $name;
}

$catName = $gato->getName();
```

#### Setter

[](#setter)

```
class Gato {
    use Setter;
    private $name;
}
$name = $gato->getName();
```

#### Data

[](#data)

Due to trait method collision, we can't compose `Getter` and `Setter` in the same class.

Instead use the `Data` trait.

```
class Gato {
    use Data;
    private $name;
}
$gato->setName('Charlie');
$name = $gato->getName();
```

### ToBuilder

[](#tobuilder)

We can mutate an existing object with the `ToBuilder` trait.

```
class Gato {
    use ToBuilder;
    private $name;
}
$chuck = $gato->toBuilder()->name('Charlie')->build();
```

### Hooks

[](#hooks)

#### \#\[PostInit\] Attribute

[](#postinit-attribute)

Apply the `#[PostInit]` attribute to any private method to be called during the `->build()` phase of the Builder.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance74

Regular maintenance activity

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~48 days

Recently: every ~36 days

Total

9

Last Release

145d ago

Major Versions

v1.0.0 → v2.0.02025-05-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b6d7e891827c823a1d8bbef786eb928fe33647f76f0ae469c3bea4757b51888?d=identicon)[amtgard](/maintainers/amtgard)

---

Top Contributors

[![esdraelon](https://avatars.githubusercontent.com/u/7896847?v=4)](https://github.com/esdraelon "esdraelon (5 commits)")[![brunojuwer](https://avatars.githubusercontent.com/u/60712131?v=4)](https://github.com/brunojuwer "brunojuwer (4 commits)")[![megiddo](https://avatars.githubusercontent.com/u/3255170?v=4)](https://github.com/megiddo "megiddo (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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