/** * Returns an instance of the Simplicity class or supplied string name * that must extend the main Simplicity class. * * @param string $class Optional string name of subclass to instanciate * @param array $opts Optional array options. * @return Simplicity */ public static final function getInstance($class = 'Simplicity', $opts = array()) { if (!is_object(self::$_instance)) { if (!class_exists($class)) { throw new Exception("Class '{$class}' does not exist."); } self::$_instance = new $class($opts); if (!self::$_instance instanceof Simplicity) { throw new Exception("Class '{$class}' does not extend the root class Simplicity."); } } return self::$_instance; }
<?php require '../simplicity/simplicity.php'; $s = Simplicity::getInstance()->start('dev');