{"id":26102475,"url":"https://github.com/nicolalazzaro/strategy-pattern-example","last_synced_at":"2026-06-05T10:31:36.444Z","repository":{"id":281386260,"uuid":"945121466","full_name":"nicolalazzaro/strategy-pattern-example","owner":"nicolalazzaro","description":"A simple example of the Strategy Pattern, demonstrating how to encapsulate different arithmetic operations.","archived":false,"fork":false,"pushed_at":"2025-03-08T17:55:57.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T18:30:23.811Z","etag":null,"topics":["example","php","strategy-pattern"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicolalazzaro.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":"2025-03-08T17:53:46.000Z","updated_at":"2025-03-08T17:57:30.000Z","dependencies_parsed_at":"2025-03-08T18:42:52.678Z","dependency_job_id":null,"html_url":"https://github.com/nicolalazzaro/strategy-pattern-example","commit_stats":null,"previous_names":["nicolalazzaro/strategy-pattern-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolalazzaro%2Fstrategy-pattern-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolalazzaro%2Fstrategy-pattern-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolalazzaro%2Fstrategy-pattern-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolalazzaro%2Fstrategy-pattern-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolalazzaro","download_url":"https://codeload.github.com/nicolalazzaro/strategy-pattern-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242744063,"owners_count":20178171,"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":["example","php","strategy-pattern"],"created_at":"2025-03-09T19:41:46.801Z","updated_at":"2025-03-09T19:41:47.321Z","avatar_url":"https://github.com/nicolalazzaro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strategy pattern\n\nStrategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.\n[Learn more here](https://refactoring.guru/design-patterns/strategy).\n\n# Considerations\n\nThis example demonstrates the **Strategy Pattern**, encapsulating arithmetic operations such as addition, subtraction, and multiplication within separate strategies.\n\nIn a real-world scenario, this approach can be used to delegate tasks like calculating the shipping cost of an order. For example, a seller might choose between different pricing strategies, such as a **per-unit cost** or a **fixed fee**. When a new pricing model is needed, a new strategy can be implemented while maintaining a consistent interface, ensuring the codebase remains flexible, organized, and easily extendable.\n\n# How to use\n\nThis example can be run using Docker. Build and start the container with the `docker compose up` command, log in and run the `php client.php` command.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolalazzaro%2Fstrategy-pattern-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolalazzaro%2Fstrategy-pattern-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolalazzaro%2Fstrategy-pattern-example/lists"}