<?php
namespace ticky;
class captcha {
public static $instance = null;
public static $config = null;
private static function getconfig() {
self::$config = config::get('captcha');
}
public static function instance($name = false) {
self::getconfig();
$type = !empty(self::$driver) ? self::$driver : 'gd';
if (false === $name) {
$name = md5(serialize(self::$config));
}
if (true === $name || !isset(self::$instance[$name])) {
$class = false === strpos($type, '\\') ? '\\ticky\\captcha\\driver\\' . $type : $type;
if (true === $name) {
return new $class(self::$config);
}
self::$instance[$name] = new $class(self::$config);
}
return self::$instance[$name];
}
}