Created
May 16, 2020 16:05
-
-
Save vineeth030/a3e24a066ce5f3fe3567d103281c874a to your computer and use it in GitHub Desktop.
Dependency Injection example
This file contains 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
class Student { | |
private $studentName; | |
public __construct($studentName){ | |
$this->studentName = $studentName; | |
} | |
} | |
class School { | |
private $student; | |
private $schoolName; | |
public __construct($schoolName, Student $student){ // Here School class is loosly coupled with Student class. | |
$this->schoolName = $schoolName; | |
$this->student = $student; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment