From ddbaf0022b7a6cddfd20ed9abfd2de27c1942406 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Tue, 23 Mar 2010 01:54:42 +0000 Subject: [PATCH] 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. --- HandBrakeCluster/Main.class.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/HandBrakeCluster/Main.class.php b/HandBrakeCluster/Main.class.php index 1227cd6..7ff73ae 100644 --- a/HandBrakeCluster/Main.class.php +++ b/HandBrakeCluster/Main.class.php @@ -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();