Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 1.21 KB

README.md

File metadata and controls

76 lines (55 loc) · 1.21 KB

opensource PHP traits

Usage

Import into a class

class Example {
  use \traits\Mixin;
}

Static mixins

static key/value mixin

Example::mixin('foo', function() {
  return 'bar';
});

static array mixin

Example::mixin([
  'foo' => function() {
    return 'bar';
  }
]);

static method call

Example::foo(); # 'bar'

Instance mixins

Specify instance methods by passing true

static key/value mixin

Example::mixin('foo', function() {
  return 'bar';
}, true);

instance array mixin

Example::mixin([
  'foo' => function() {
    return 'bar';
  }
], true);

instance method call

$example = new Example;
Example->foo(); # 'bar'

License

MIT