-
-
Save Ideneal/762d03bb9cf0c4c1d8a78bc16a09967b to your computer and use it in GitHub Desktop.
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
<?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... | |
} | |
} |
I think on line 18 it will be
public function __construct(MySQLConnection $dbConnection) {
No, because an entity should depend on abstractions and not on concretions.
@Idenela I think on line 19 , $this->$dbConnection = $dbConnection; this should change to $this->dbConnection = $dbConnection;
@Vijaysinh Updated! Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think on line 18 it will be
public function __construct(MySQLConnection $dbConnection) {