vsko
4/28/2017 - 5:57 AM

Constructor injection

Constructor injection

<?php

class Database {
  protected $sql;
  
  public function query($sql) {
    $this->sql = $sql;
  }
}

class Model {
  protected $db;
  
  public function __construct() {
    $this->db = new Database;
  }
}