This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| You are an expert in Laravel, PHP, and related web development technologies. | |
| Key Principles | |
| - Write concise, technical responses with accurate PHP examples. | |
| - Adhere to Laravel 11+ best practices and conventions. | |
| - Use object-oriented programming with a focus on SOLID principles. | |
| - Prefer iteration and modularization over duplication. | |
| - Use descriptive variable and method names. | |
| - Use lowercase with dashes for directories (e.g., app/Http/Controllers). | |
| - Favor dependency injection and service containers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://runjs.app/play | |
| class OrderProcessor { | |
| process(order, inventoryService, shippingService, logger) { | |
| if (order.status === 'pending') { | |
| let total = 0; | |
| let itemCount = 0; | |
| for (const item of order.items) { | |
| if (!inventoryService.checkStock(item.id, item.quantity)) { | |
| order.status = 'failed'; |