{"id":17277782,"url":"https://github.com/sassman/edu-decorator-pattern-php","last_synced_at":"2025-06-13T09:08:08.793Z","repository":{"id":137877794,"uuid":"107966106","full_name":"sassman/edu-decorator-pattern-php","owner":"sassman","description":"Illustrating the usage and the use case of the decorator pattern.","archived":false,"fork":false,"pushed_at":"2017-10-23T10:30:21.000Z","size":495,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T15:36:38.289Z","etag":null,"topics":["decorator-pattern","design-patterns","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sassman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-10-23T10:21:30.000Z","updated_at":"2019-08-24T18:04:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc44c2c4-ebb5-4449-b13c-842c5ceee6f0","html_url":"https://github.com/sassman/edu-decorator-pattern-php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sassman%2Fedu-decorator-pattern-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sassman%2Fedu-decorator-pattern-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sassman%2Fedu-decorator-pattern-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sassman%2Fedu-decorator-pattern-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sassman","download_url":"https://codeload.github.com/sassman/edu-decorator-pattern-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245668641,"owners_count":20653008,"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":["decorator-pattern","design-patterns","php"],"created_at":"2024-10-15T09:09:56.304Z","updated_at":"2025-03-26T14:19:39.246Z","avatar_url":"https://github.com/sassman.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"decorator-pattern-php\n=====================\n\nIllustrating the usage and the use case of the decorator pattern.\nThis is only educational material. No production grade code.\n\nThe Problem is code like this:\n```php\n\u003c?php\n\nnamespace BurgerShop;\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\n$bill = new Bill();\n$bill-\u003eaddProduct(new Hamburger());\n$bill-\u003eaddProduct(new CheeseburgerWithOnion());\n$bill-\u003eaddProduct(new CheeseburgerWithDoubleCheese());\n\nprintf(\"==============================\\n\");\nprintf(\"Total is %2.2f\\n\", $bill-\u003egetTotal());\n```\n\nThe solution is evolving to\n\n```php\n\u003c?php\n\nnamespace BurgerShop;\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\n$bill = new Bill();\n$bill-\u003eaddProduct(new Hamburger());\n$bill-\u003eaddProduct(new Cheeseburger(new Onion()));\n$bill-\u003eaddProduct(new Cheeseburger(new Cheese()));\n\nprintf(\"==============================\\n\");\nprintf(\"Total is %2.2f\\n\", $bill-\u003egetTotal());\n```\n\nto improve the design, flexibility but most importantly the maintainability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsassman%2Fedu-decorator-pattern-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsassman%2Fedu-decorator-pattern-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsassman%2Fedu-decorator-pattern-php/lists"}