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:
@@ -83,7 +83,7 @@ class HandBrakeCluster_Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Special case: All exceptions are stored in the same file
|
// 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');
|
require_once('HandBrakeCluster/Exceptions.class.php');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -114,6 +114,18 @@ class HandBrakeCluster_Main {
|
|||||||
}
|
}
|
||||||
return true;
|
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();
|
HandBrakeCluster_Main::initialise();
|
||||||
|
|||||||
Reference in New Issue
Block a user