Untitled
user_4333156
php
a year ago
594 B
10
Indexable
<?php
class MySQLDatabase {
public function saveOrder($order) {
// Logic to save the order in MySQL database
echo "Saving order to MySQL database.\n";
}
}
class OrderService {
private $db;
public function __construct() {
$this->db = new MySQLDatabase(); // Direct dependency on a specific implementation
}
public function placeOrder($order) {
// Some logic for placing the order
$this->db->saveOrder($order);
}
}
// Usage
$orderService = new OrderService();
$orderService->placeOrder('Order 1');
Editor is loading...
Leave a Comment