{"id":25952103,"url":"https://github.com/osamaayub/object-oriented-programming-with-php","last_synced_at":"2025-03-04T14:33:03.903Z","repository":{"id":279790308,"uuid":"939979773","full_name":"osamaayub/Object-Oriented-Programming-With-Php","owner":"osamaayub","description":"object oriented programming with php and learning concepts regarding classes as well.","archived":false,"fork":false,"pushed_at":"2025-02-27T12:32:32.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T17:40:10.506Z","etag":null,"topics":["abstraction","classes-and-objects","encapsulation","inheritence","oop-principles","php7","polymorphism","setters-and-getters"],"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/osamaayub.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":"2025-02-27T12:24:25.000Z","updated_at":"2025-02-27T12:34:16.000Z","dependencies_parsed_at":"2025-02-27T17:40:27.832Z","dependency_job_id":"01acc1e4-f6d0-495e-9986-7974b405aaf7","html_url":"https://github.com/osamaayub/Object-Oriented-Programming-With-Php","commit_stats":null,"previous_names":["osamaayub/oop-php"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamaayub%2FObject-Oriented-Programming-With-Php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamaayub%2FObject-Oriented-Programming-With-Php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamaayub%2FObject-Oriented-Programming-With-Php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osamaayub%2FObject-Oriented-Programming-With-Php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osamaayub","download_url":"https://codeload.github.com/osamaayub/Object-Oriented-Programming-With-Php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241865313,"owners_count":20033327,"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":["abstraction","classes-and-objects","encapsulation","inheritence","oop-principles","php7","polymorphism","setters-and-getters"],"created_at":"2025-03-04T14:33:02.970Z","updated_at":"2025-03-04T14:33:03.895Z","avatar_url":"https://github.com/osamaayub.png","language":"PHP","readme":"# Stage-4 PHP with Object-Oriented Programming\n\nThis repository contains simple scenario-based tasks to practice Object-Oriented Programming (OOP) in PHP.\n\n## Task 1: Create a Basic Product Class\n\n### Objective\nUnderstand the basics of classes, objects, properties, and methods.\n\n### Details\nCreate a `Product` class in PHP with the following properties:\n- `name`\n- `price`\n- `description`\n\nImplement methods to set and get these properties, and a method `displayProductDetails()` to output the product details in a readable format.\n\n### Requirements\n- The class should have **private** properties.\n- Use **constructor overloading** to initialize the object properties.\n- Implement **getter and setter** methods for each property.\n- Create an instance of the `Product` class and use its methods to demonstrate functionality.\n\n---\n\n## Task 2: Implement a Simple Shopping Cart System\n\n### Objective\nPractice using classes, objects, and basic object interactions.\n\n### Details\nCreate a `ShoppingCart` class that can hold multiple `Product` objects. The cart should support adding, removing, and calculating the total price of products.\n\n### Requirements\n- The `ShoppingCart` class should have a **private property** to store an array of `Product` objects.\n- Implement the following methods:\n  - `addProduct(Product $product)` - Adds a product to the cart.\n  - `removeProduct(Product $product)` - Removes a product from the cart.\n  - `calculateTotalPrice()` - Calculates and returns the total price of all products in the cart.\n- Demonstrate functionality by adding and removing products and calculating the total price.\n\n---\n\n## Task 3: Develop a Library Management System\n\n### Objective\nUnderstand inheritance and polymorphism.\n\n### Details\nCreate a library management system with different types of materials: **Book, Magazine, and DVD**. Each material type should inherit from a base class `LibraryMaterial` and override its methods where necessary.\n\n### Requirements\n- The `LibraryMaterial` class should have properties like:\n  - `title`\n  - `author`\n  - `ISBN`\n  - `publicationYear`\n- Create subclasses `Book`, `Magazine`, and `DVD`, each with specific properties like:\n  - `pageCount` (for books)\n  - `duration` (for DVDs)\n- Implement methods in the base class and override them in the subclasses to demonstrate **polymorphism**.\n- Create a method `displayMaterialDetails()` that outputs the details of each material.\n\n---\n\n## Task 4: Build a Simple Contact Management System\n\n### Objective\nLearn about encapsulation and data validation.\n\n### Details\nCreate a `Contact` class that represents a person's contact information (e.g., name, email, phone number). Include validation for email format and phone number length.\n\n### Requirements\n- Use **private properties** for `name`, `email`, and `phone number`.\n- Implement **setter methods** that include validation:\n  - Ensure the email contains an \"@\" symbol.\n  - Validate the phone number length.\n- Implement **getter methods** to retrieve contact information.\n- Create a test script that demonstrates setting and getting properties with validation.\n\n---\n\n## How to Run the Code\n1. Ensure you have PHP installed on your system.\n2. Clone this repository and navigate to the respective task directories.\n3. Run the PHP files using the command:\n   ```sh\n   php filename.php\n   ```\n4. Observe the output to verify the implemented functionalities.\n\n---\n\n## Conclusion\nThese tasks help in understanding fundamental OOP concepts in PHP, including **encapsulation, inheritance, polymorphism, and object interactions**. Completing them will enhance your PHP development skills and prepare you for real-world applications.\n\nHappy Coding! 🚀\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosamaayub%2Fobject-oriented-programming-with-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosamaayub%2Fobject-oriented-programming-with-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosamaayub%2Fobject-oriented-programming-with-php/lists"}