{"id":16760417,"url":"https://github.com/ryanve/traits","last_synced_at":"2025-04-10T17:41:08.107Z","repository":{"id":7833281,"uuid":"9204698","full_name":"ryanve/traits","owner":"ryanve","description":"Opensource PHP traits","archived":false,"fork":false,"pushed_at":"2014-01-14T16:25:43.000Z","size":280,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T18:56:27.950Z","etag":null,"topics":["php","php-traits"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-03T20:52:33.000Z","updated_at":"2020-12-09T04:07:12.000Z","dependencies_parsed_at":"2022-09-13T19:41:07.055Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/traits","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ftraits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ftraits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ftraits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Ftraits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/traits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262180,"owners_count":21074258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-traits"],"created_at":"2024-10-13T04:23:26.958Z","updated_at":"2025-04-10T17:41:08.085Z","avatar_url":"https://github.com/ryanve.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [traits](../../) ([0.9](../../releases))\n#### opensource [PHP traits](http://php.net/manual/en/language.oop5.traits.php)\n\n- [`Data`](Data.php) includes data/removeData methods.\n- [`Emitter`](Emitter.php) is an event emitter based on [EventEmitter](http://nodejs.org/api/events.html).\n- [`Mixin`](Mixin.php) is for making extensible [classes](http://php.net/manual/en/language.oop5.php).\n- [`Aware`](Aware.php) includes instantiation and context helpers.\n\n## Usage \n\n### Import into a class\n\n```php\nclass Example {\n  use \\traits\\Mixin;\n}\n```\n\n### Static mixins\n\n#### static key/value mixin\n\n```php\nExample::mixin('foo', function() {\n  return 'bar';\n});\n```\n\n#### static array mixin\n\n```php\nExample::mixin([\n  'foo' =\u003e function() {\n    return 'bar';\n  }\n]);\n```\n\n#### static method call\n\n```php\nExample::foo(); # 'bar'\n```\n\n### Instance mixins\n\nSpecify instance methods by passing `true`\n\n#### static key/value mixin\n\n```php\nExample::mixin('foo', function() {\n  return 'bar';\n}, true);\n```\n\n#### instance array mixin\n\n```php\nExample::mixin([\n  'foo' =\u003e function() {\n    return 'bar';\n  }\n], true);\n```\n\n#### instance method call\n\n```php \n$example = new Example;\nExample-\u003efoo(); # 'bar'\n```\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Ftraits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Ftraits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Ftraits/lists"}