Skip to content

Instantly share code, notes, and snippets.

@Ideneal
Last active October 26, 2021 10:41
Show Gist options
  • Save Ideneal/762d03bb9cf0c4c1d8a78bc16a09967b to your computer and use it in GitHub Desktop.
Save Ideneal/762d03bb9cf0c4c1d8a78bc16a09967b to your computer and use it in GitHub Desktop.
<?php
interface DBConnectionInterface {
public function connect();
}
class MySQLConnection implements DBConnectionInterface {
public function connect() {
// Return the MySQL connection...
}
}
class UserDB {
private $dbConnection;
public function __construct(DBConnectionInterface $dbConnection) {
$this->dbConnection = $dbConnection;
}
public function store(User $user) {
// Store the user into a database...
}
}
@Ideneal
Copy link
Author

Ideneal commented Oct 26, 2021

@Vijaysinh Updated! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment