Skip to content

Provides a way to extend static classes with new methods

Notifications You must be signed in to change notification settings

php-protein/extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

Provides a way to extend static classes with new methods

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages