PHPackages                             jcstrandburg/extension-methods - 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. jcstrandburg/extension-methods

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

jcstrandburg/extension-methods
==============================

Extension method library

v1.1(7y ago)0261MITPHPPHP ^7.0

Since Sep 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jcstrandburg/ExtensionMethods)[ Packagist](https://packagist.org/packages/jcstrandburg/extension-methods)[ RSS](/packages/jcstrandburg-extension-methods/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

ExtensionMethods
================

[](#extensionmethods)

This library supports C# and kotlin style extension methods for any class that uses the `Extensible` trait. This library differs from some other libraries in that it is not possible for extension methods to get access to private properties and methods, allowing library authors to maintain proper encapsulation.

Installing
----------

[](#installing)

`composer require jcstrandburg\extension-methods`

Usage
-----

[](#usage)

```
class Person
{
  use trait Extensible;

  public function __construct(string $firstname, string $lastname) {
    $this->firstname = $firstname;
    $this->lastname = $lastname;
  }

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

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

  private $firstname;
  private $lastname;
}

Person::extend('getFullname', function (Person $x) {
  return $x->getFirstname() . ' ' . $x->getLastname();
});

$bob = new Person('Bob', 'Roberts');
$bob->getFullname() == 'Bob Roberts';
```

Version History
---------------

[](#version-history)

### Unreleased

[](#unreleased)

### 1.1

[](#11)

#### Changed

[](#changed)

- Reworked internal implementation to fix several issues with inheritance. It is now possible to register extension methods for classes extending a base class with the `Extensible` trait even if the extending class itself doesn't have the `Extensible` trait.

### 1.0

[](#10)

#### Added

[](#added)

- `Extensible` trait

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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

Total

2

Last Release

2743d ago

### Community

Maintainers

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

---

Top Contributors

[![jcstrandburg](https://avatars.githubusercontent.com/u/6415841?v=4)](https://github.com/jcstrandburg "jcstrandburg (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jcstrandburg-extension-methods/health.svg)

```
[![Health](https://phpackages.com/badges/jcstrandburg-extension-methods/health.svg)](https://phpackages.com/packages/jcstrandburg-extension-methods)
```

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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