Skip to content

Instantly share code, notes, and snippets.

@vineeth030
Created May 16, 2020 16:05
Show Gist options
  • Save vineeth030/a3e24a066ce5f3fe3567d103281c874a to your computer and use it in GitHub Desktop.
Save vineeth030/a3e24a066ce5f3fe3567d103281c874a to your computer and use it in GitHub Desktop.
Dependency Injection example
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