3 ms·
You can always add functions via mixin. I'll see what I can do about the warnings.
by bwh2 15y ago
You can always add functions via mixin. I'll see what I can do about the warnings.
- fooyc 15y agoHow can I add a mixin to the __ class without editing it ?
- bwh2 15y agoJust copying this from the docs, but you can pass an array of functions to mixin: __::mixin(array( 'capitalize'=> function($string) { return ucwords($string); } )); __::capitalize('moe'); // 'Moe'
- skrebbel 15y agoBut in a way, using the namespace like suggested is much more PHP-ish. After all, your class does not have sensible instances. There is not much OOP about it. Where there is something not-much-OOP about something, PHP supplies global functions (compare md5() to 5 lines of Java code) instead of classes. So, using global functions would. in many ways, be much more PHP-ish than using static class methods (which is more Java-ish if you ask me). Of course, you don't want to pollute the global namespace too much, so using the '_' namespace sounds excellent. I really like the idea.
- bwh2 15y agoNamespaces might be more PHP-ish, but I was primarily concerned with being Underscore-ish. I'm also not entirely opposed to the namespace approach, but syntactically I would rather call: __::foo('bar'); than use _; __\foo('bar');