- /**
- * Getter for a singleton instance of this class
- *
- * @return $configInstance A singleton instance of this class
- */
- public static final function getSelfInstance () {
- // is the instance there?
- if (is_null(self::$configInstance)) {
- // Create a config instance
- self::$configInstance = new FrameworkConfiguration();
- } // END - if
-
- // Return singleton instance
- return self::$configInstance;
- }
-
- /**
- * Converts dashes to underscores, e.g. useable for configuration entries
- *
- * @param $str The string with maybe dashes inside
- * @return $str The converted string with no dashed, but underscores
- * @throws NullPointerException If $str is null
- * @throws InvalidArgumentException If $str is empty
- */
- private final function convertDashesToUnderscores ($str) {
- // Is it null?
- if (is_null($str)) {
- // Throw NPE
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (empty($str)) {
- // Entry is empty
- throw new InvalidArgumentException('str is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- }
-
- // Convert them all
- $str = str_replace('-', '_', $str);
-
- // Return converted string
- return $str;
- }
-
- /**
- * Setter for default time zone (must be correct!)
- *
- * @param $timezone The timezone string (e.g. Europe/Berlin)
- * @return $success If timezone was accepted
- * @throws NullPointerException If $timezone is NULL
- * @throws InvalidArgumentException If $timezone is empty
- */
- public final function setDefaultTimezone ($timezone) {
- // Is it null?
- if (is_null($timezone)) {
- // Throw NPE
- throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
- } elseif (!is_string($timezone)) {
- // Is not a string
- throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- } elseif (empty($timezone)) {
- // Entry is empty
- throw new InvalidArgumentException('timezone is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY);
- }
-
- // Default success
- $success = FALSE;
-
- /*
- * Set desired time zone to prevent date() and related functions to
- * issue an E_WARNING.
- */
- $success = date_default_timezone_set($timezone);
-
- // Return status
- return $success;
- }
-