Version 1.2 coming soon
I’m working on a new version which introduces a bit more flexibility when it comes to overriding existing class methods with mutated methods. Currently, one can only add new ‘mutated’ methods but not modify existing methods. (However, you can modify ‘mutated’ methods). Version 1.2 will address this, as well as property visibility for mutated methods (private/protected).
- [Aug 11 2013]: 1.1.0 – Extending from a mutated class now inherits those mutated methods.
- [Aug 10 2013]: Initial Release
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.
If you purchase, please consider rating the product! – Thanks
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.
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.
预览 Class Mutations - Dynamically Add Methods 等待分享
Version 1.2 coming soonI’m working on a new version which introduces a bit more flexibility when it