jeudi 31 mars 2022

Which kind of design pattern is this?

So I have this code below and wanted to know from which kind of PHP design patterns is this?


  public static function newInstance($driver) {
    $file = dirname(_FILE_).'/drivers/'.$driver.'.php';
    if (include_once($file)) {
      $driverClass = $driver . 'Driver';
      return new $driverClass;
    } else {
      throw new Exception('Database driver not found');
    }
  }
}


$db = DatabaseDriver::newInstance('MySQL');

Aucun commentaire:

Enregistrer un commentaire