proteins/extensions

Provides a way to extend static classes with new methods

Maintainers

Package info

github.com/php-protein/extensions

pkg:composer/proteins/extensions

Statistics

Installs: 38

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.3 2019-05-28 14:31 UTC

This package is auto-updated.

Last update: 2026-03-01 00:28:03 UTC


README

Protein | Extensions

Provides a way to extend static classes with new methods

Install

composer require proteins/extensions

Include the trait in your classes via :

use Proteins\Extensions;

class Test {
    use Extensions;
}

Extend a class with new methods

class Test {
  use Extensions;
  public static function foo(){ echo "Foo!"; }
}

Test::foo(); // Foo!
Test::bar(); // Fatal error: Call to undefined method Test::bar

Test::extend([
  'bar' => function(){ echo "Bar!"; },
]);

Test::bar();  // Bar!