Class Mutations – Dynamically Add Methods (Miscellaneous)

What’s this?

A pack of three classes that enables you to dynamically add new methods to a class or object using closures (anonymous functions). Both static and instance methods can be added.

Why?

If you’re developing a website or web application that needs to be modular or perhaps provide an API for plugin/module development, this mutations system can be very useful in providing flexibility.

What’s included?

Included in the zip file is an examples directory with four commented PHP example files that show you what’s possible and the different implementations available to your version of PHP.

There are three classes, plus a trait. If you’re on PHP version 5.4 or later, I recommend using the trait, it’s a simple one-liner (or a three-liner if you need to implement your own __call and __callStatic methods)

Need any help?

If you need any help or have any questions, feel free to give me a comment or send me message via email.

Cheers!

Download Class Mutations – Dynamically Add Methods (Miscellaneous)

Leave a Reply

Your email address will not be published. Required fields are marked *