Added isset method

Returns the first parameter if it is set, otherwise returns the default value
unless the default value is the name of a valid HBC Exception class, in which case an instance of that exception is thrown.
This commit is contained in:
2010-03-23 01:54:42 +00:00
parent 048bcbd74f
commit ddbaf0022b

View File

@@ -83,7 +83,7 @@ class HandBrakeCluster_Main {
}
// Special case: All exceptions are stored in the same file
if (preg_match('/^HandBrakeCluster_Exception_/', $classname)) {
if (preg_match('/^HandBrakeCluster_Exception/', $classname)) {
require_once('HandBrakeCluster/Exceptions.class.php');
return;
}
@@ -114,6 +114,18 @@ class HandBrakeCluster_Main {
}
return true;
}
public static function issetelse($var, $default = null) {
if (isset($var)) {
return $var;
}
if (is_subclass_of($default, HandBrakeCluster_Exception)) {
throw new $e();
}
return $default;
}
}
HandBrakeCluster_Main::initialise();