{"id":15025460,"url":"https://github.com/pbxg33k/php-traits","last_synced_at":"2025-04-09T20:04:09.992Z","repository":{"id":57037009,"uuid":"59566614","full_name":"PBXg33k/php-traits","owner":"PBXg33k","description":"A collection of PHP Traits to make life with PHP (a bit) easier","archived":false,"fork":false,"pushed_at":"2022-10-15T21:40:13.000Z","size":53,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T20:04:04.494Z","etag":null,"topics":["helpers","php","php-7","php-library","php-traits","php7","traits"],"latest_commit_sha":null,"homepage":null,"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/PBXg33k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-24T11:18:35.000Z","updated_at":"2024-09-02T10:43:54.000Z","dependencies_parsed_at":"2022-08-24T06:40:42.662Z","dependency_job_id":null,"html_url":"https://github.com/PBXg33k/php-traits","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PBXg33k%2Fphp-traits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PBXg33k%2Fphp-traits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PBXg33k%2Fphp-traits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PBXg33k%2Fphp-traits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PBXg33k","download_url":"https://codeload.github.com/PBXg33k/php-traits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103865,"owners_count":21048245,"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":["helpers","php","php-7","php-library","php-traits","php7","traits"],"created_at":"2024-09-24T20:02:22.823Z","updated_at":"2025-04-09T20:04:09.964Z","avatar_url":"https://github.com/PBXg33k.png","language":"PHP","readme":"[![Latest Stable Version](https://poser.pugx.org/pbxg33k/pbxg33k-traits/v/stable)](https://packagist.org/packages/pbxg33k/pbxg33k-traits) [![Total Downloads](https://poser.pugx.org/pbxg33k/pbxg33k-traits/downloads)](https://packagist.org/packages/pbxg33k/pbxg33k-traits) [![Latest Unstable Version](https://poser.pugx.org/pbxg33k/pbxg33k-traits/v/unstable)](https://packagist.org/packages/pbxg33k/pbxg33k-traits) [![License](https://poser.pugx.org/pbxg33k/pbxg33k-traits/license)](https://packagist.org/packages/pbxg33k/pbxg33k-traits) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PBXg33k/php-traits/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/PBXg33k/php-traits/?branch=master) [![Coverage Status](https://coveralls.io/repos/github/PBXg33k/php-traits/badge.svg)](https://coveralls.io/github/PBXg33k/php-traits)\n\n# PBXg33k's PHP Traits\n\nThis repository is a collection of traits to make life with PHP easier\n\n## Installation\n\nAdd the package-skeleton package to your `composer.json` file.\n\n``` json\n{\n    \"require\": {\n        \"pbxg33k/pbxg33k-traits\": \"1.0.*\"\n    }\n}\n```\n\nOr via the command line in the root of your project's installation.\n\n``` bash\n$ composer require \"pbxg33k/pbxg33k-traits*\"\n```\n\n## Traits\n\n\n- **HydratableTrait** Allows you to easily hydrate classes from arrays. An example is importing data from external APIs \n- **ReflectionTrait** Allows you to do extra things with Reflection (ie: get property class from @var block)\n- **PropertyTrait** Set property values without worrying about property visibility or setters\n\n## Usage\nClick [here](http://php.net/manual/en/language.oop5.traits.php) to read about using traits on PHP's own manual.\n\n### HydratableTrait ###\n```php\nclass Foo \n{\n    use Pbxg33k\\Traits\\HydratableTrait;\n    // Rest of your class\n\n    // Example property, imagine it has proper getter/setter\n    protected $randomProperty;\n}\n\n// Somewhere else in code\n$foo = new Foo();\n$foo-\u003ehydrateClass(['randomProperty' =\u003e 'value']);\n\nvar_dump($foo-\u003egetRandomProperty()); // \"value\"\n```\n\nHydratableTrait trait allows you to hydrate your class properties easily by passing an array to hydrateClass().\nThis trait will automagically assign matching keys to properties and instantiate supported classes.\n\n\n### ReflectionTrait ###\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request\n\n## Changelog\n\nPlease see [CHANGELOG.md](CHANGELOG.md)\n\n\n## License\n\nThe MIT License (MIT)\nCopyright (c) 2016 Oguzhan Uysal.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbxg33k%2Fphp-traits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpbxg33k%2Fphp-traits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbxg33k%2Fphp-traits/lists"}