Example #1
0
 /**
  * Register a new driver with the Database
  *
  * @param string $name  The name/alias of the driver
  * @param string $class The class name of the driver (Full class name required)
  *
  * @return $this
  * @throws Exception\Database
  */
 public function registerDriver($name, $class)
 {
     $interface = 'Aviogram\\DAL\\Databases\\Shared\\DriverInterface';
     // Check if the name is not already taken
     if (array_key_exists($name, $this->drivers) === true) {
         throw Exception\Driver::driverExists($name);
     }
     // Check if the class even exists
     if (class_exists($class) === false) {
         throw Exception\Driver::driverClassNotFound($name, $class);
     }
     // Check if the class implements the required interface
     if (is_subclass_of($class, $interface) === false) {
         throw Exception\Driver::invalidClassDriver($name, $class, $interface);
     }
     // Register the driver
     $this->drivers[$name] = $class;
     // Return the platform instance
     return $this;
 }