PHPackages                             nabeghe/buildify - 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. nabeghe/buildify

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

nabeghe/buildify
================

Buildify improves PHP OOP with enhanced getter and setter functionality inspired by Builder and Fluent Patterns.

1.0.2(1y ago)35MITPHPPHP &gt;=7.4

Since Oct 21Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/nabeghe/buildify-php)[ Packagist](https://packagist.org/packages/nabeghe/buildify)[ Docs](https://github.com/nabeghe/buildify-php)[ RSS](/packages/nabeghe-buildify/feed)WikiDiscussions master Synced 1mo ago

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

Buildify (Feeling OOP Vibes in PHP!)
====================================

[](#buildify-feeling-oop-vibes-in-php)

> Buildify improves PHP OOP with enhanced getter and setter functionality inspired by Builder and Fluent Patterns.

Buildify is a lightweight PHP package designed to facilitate the dynamic creation and management of objects through a fluent interface. But the main part is that you have full control over the getter and setter processes, You can define a getter and setter for each field that will be executed when retrieving and modifying the value. You can also take advantage of the refresh method, which is triggered whenever any field in the object is updated. Additionally, there is the ability to modify various settings as well.

---

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/buildify
```

---

### Example - Person Class

[](#example---person-class)

```
/**
 * Person Class.
 *
 * Properties:
 *
 * @property string|null $firstName
 * @property string|null $lastName
 * @property string|null $gender
 * @property string|null $maritalStatus
 * @property bool $isMarried
 * @property bool $isSingle
 * @property int|null $penisSize
 * @property int|null $vaginalSize
 *
 * Getters/Setters:
 *
 * @method self|string|null firstName(string|null $value = false)
 * @method self|string|null lastName(string|null $value = false)
 * @method self|string|null gender(string|null $value = false)
 * @method self|string|null maritalStatus(string|null $value = false)
 * @method self|int|null penisSize(int|null $value = false)
 * @method self|bool isMarried()
 * @method self|bool isSingle()
 * @method self|int|null vaginalSize(int|null $value = false)
 */
class Person extends \Nabeghe\Buildify\Buildify
{
    // You can use `BuildifyTrait` instead of extending the Buildify class.
    // You can also override class constants to enable or disable various features.

    public const REFRESHABLE = true;

    public function defaults(): array
    {
        return [
            'gender' => 'unknown',
            'maritalStatus' => 'single',
        ];
    }

    public function refresh($name, $newValue, $oldValue): void
    {
        parent::refresh($name, $newValue, $oldValue);

        if ($newValue == $oldValue) {
            return;
        }

        if ($name == 'gender') {
            if ($this->gender === 'male') {
                unset($this->vaginalSize);
                echo "Vaginal Size Removed!\n";
            } elseif ($this->gender === 'female') {
                unset($this->penisSize);
                echo "Penis Size Removed!\n";
            }
        }
    }

    protected function setPenisSize(&$value): bool
    {
        if ($this->gender == 'male') {
            return true;
        }

        echo "The penis size is not applicable to women.\n";
        return false;
    }

    protected function setVaginalSize(&$value): bool
    {
        if ($this->gender == 'female') {
            return true;
        }

        echo "The vaginal size is not applicable to men.\n";
        return false;
    }

    protected function setFirstNameLength(&$value): bool
    {
        return strlen($this->firstName);
    }

    protected function getIsMarried(): bool
    {
        return $this->maritalStatus === 'married';
    }

    protected function setIsMarried(&$value): bool
    {
        return false;
    }

    protected function getIsSingle(): bool
    {
        return $this->maritalStatus === 'single';
    }

    protected function setISingle(&$value): bool
    {
        return false;
    }
}

$person = Person::new()
    ->firstName('Hadi')
    ->lastName('Akbarzadeh');

echo "First Name = ".$person->firstName."\n";
echo "Last Name  = ".$person->lastName()."\n";
echo "Gender     = ".$person->gender()."\n";
echo "-----\n";

$person->gender = 'male';
echo "New Gender = ".$person->gender."\n";
echo "-----\n";

$person->penisSize = 1; // lol
echo "Penis Size = ".$person->penisSize."\n";
echo "-----\n";

echo "Setting the vaginal size to 2 ...\n";
$person->vaginalSize = 2; // It won't be set.
echo "-----\n";

$person->gender = 'female';
$person->vaginalSize = 3;
$person->firstName = 'Hermione';
echo "First Name = ".$person->firstName."\n";
echo "Last Name = ".$person->lastName."\n";
echo "New Gender = ".$person->gender."\n";
echo "Vaginal Size = ".$person->vaginalSize."\n";
echo "-----\n";

echo "Marital Status = ".$person->maritalStatus()."\n";
echo $person->isMarried ? "Married\n" : "Not Married\n";
echo $person->isSingle ? "Single\n" : "Not Single\n";
$person->maritalStatus('married');
echo "New Marital Status = ".$person->maritalStatus()."\n";
echo $person->isMarried ? "Married\n" : "Not Married\n";
echo $person->isSingle ? "Single\n" : "Not Single\n";

/*
    First Name = Hadi
    Last Name  = Akbarzadeh
    Gender     = unknown
    -----
    New Gender = male
    -----
    Penis Size = 1
    -----
    Setting the vaginal size to 2 ...
    The vaginal size is not applicable to men.
    -----
    First Name = Hermione
    Last Name = Akbarzadeh
    New Gender = female
    Vaginal Size = 3
    -----
    Marital Status = single
    Not Married
    Single
    New Marital Status = married
    Married
    Not Single
 */
```

---

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance47

Moderate activity, may be stable

Popularity7

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.

###  Release Activity

Cadence

Every ~10 days

Total

3

Last Release

555d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dae1bf378bcf40fe55c193160377d613d628188587554a3fb11cdec6f0521ba1?d=identicon)[nabeghe](/maintainers/nabeghe)

---

Top Contributors

[![nabeghe](https://avatars.githubusercontent.com/u/12207627?v=4)](https://github.com/nabeghe "nabeghe (5 commits)")

---

Tags

design-patterndesign-patternsfluent-designgetterlibraryphpphp-helperphp-librarysettertraithelperlibraryclasstraitobjectbuildersetfluentdesign patterngetgettersettersupportOOPfluent-interfacebuilder design pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nabeghe-buildify/health.svg)

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

###  Alternatives

[antares/accessible

PHP library that allows you to define your class' getters, setters and constructor with docblock annotations.

123.9k1](/packages/antares-accessible)[antares/accessible-bundle

A bundle to easily use Accessible in Symfony projects.

153.8k](/packages/antares-accessible-bundle)[usmanhalalit/get-set-go

Dynamic Setter-Getter for PHP 5.4+

1813.4k1](/packages/usmanhalalit-get-set-go)

PHPackages © 2026

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