{"id":22248975,"url":"https://github.com/purplebooth/encapsulation-traits","last_synced_at":"2025-07-22T21:35:55.238Z","repository":{"id":136339147,"uuid":"99517333","full_name":"PurpleBooth/encapsulation-traits","owner":"PurpleBooth","description":"Breaking Encapsulation with traits in PHP","archived":false,"fork":false,"pushed_at":"2024-10-01T20:10:16.000Z","size":4,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T11:49:50.222Z","etag":null,"topics":["oop","php","traits"],"latest_commit_sha":null,"homepage":"https://dev.to/billiecodes/breaking-encapsulation-with-traits-in-php","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/PurpleBooth.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-06T22:41:29.000Z","updated_at":"2017-09-05T21:40:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"615c903b-4c64-45eb-bad8-f7fca10eacff","html_url":"https://github.com/PurpleBooth/encapsulation-traits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PurpleBooth/encapsulation-traits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PurpleBooth%2Fencapsulation-traits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PurpleBooth%2Fencapsulation-traits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PurpleBooth%2Fencapsulation-traits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PurpleBooth%2Fencapsulation-traits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PurpleBooth","download_url":"https://codeload.github.com/PurpleBooth/encapsulation-traits/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PurpleBooth%2Fencapsulation-traits/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266578680,"owners_count":23951150,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["oop","php","traits"],"created_at":"2024-12-03T06:21:02.154Z","updated_at":"2025-07-22T21:35:55.189Z","avatar_url":"https://github.com/PurpleBooth.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Breaking Encapsulation with traits in PHP\n=========================================\n\nTraits in PHP are dangerous because they allow the accidental breaking of encapsulation, for no real gain. In this\nexample you can see an example of traits vs an invokable class, you could use any `callable` type here for the same\neffect. You can avoid this by being careful and not setting any member variables in traits, but everyone makes mistakes,\nso why risk it, when the encapsulation comes for free with `callable` types?\n\nRun it using\n\n```\ncomposer run\n```\n\nIt requires PHP 7.1 or greater.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurplebooth%2Fencapsulation-traits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurplebooth%2Fencapsulation-traits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurplebooth%2Fencapsulation-traits/lists"}