X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=721e4ec52556f44fd7924358be9a83ba200167ee;hp=322bd28263da9984da6176ce53c2c31516f32a58;hb=63f5632b0c5d2cebf8dd0940fdab561f86470f80;hpb=b954ccaa3dbfc59ddc76e463d2980a5dc204cc9f diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 322bd282..721e4ec5 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -50,8 +50,10 @@ use CoreFramework\Visitor\Visitor; // Import SPL stuff use \stdClass; +use \InvalidArgumentException; use \Iterator; use \ReflectionClass; +use \SplFileInfo; /** * The simulator system class is the super class of all other classes. This @@ -465,7 +467,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Set configuration instance if no registry ... if (!$this instanceof Register) { // ... because registries doesn't need to be configured - $this->setConfigInstance(FrameworkConfiguration::getSelfInstance()); + $this->setConfigInstance(FrameworkBootstrap::getConfigurationInstance()); } // END - if // Is the startup time set? (0 cannot be true anymore) @@ -1749,7 +1751,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ); // Output it - ApplicationEntryPoint::app_exit(sprintf('
+ ApplicationEntryPoint::exitApplication(sprintf('
%s debug output:
@@ -1852,7 +1854,7 @@ Loaded includes: // Try it try { // Get a debugger instance - $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className); + $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className); } catch (NullPointerException $e) { // Didn't work, no instance there exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber)); @@ -1982,8 +1984,22 @@ Loaded includes: * * @param $str The string with maybe dashes inside * @return $str The converted string with no dashed, but underscores - */ - public static final function convertDashesToUnderscores ($str) { + * @throws NullPointerException If $str is null + * @throws InvalidArgumentException If $str is empty + */ + public static function convertDashesToUnderscores ($str) { + // Is it null? + if (is_null($str)) { + // Throw NPE + throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_string($str)) { + // Entry is empty + throw new InvalidArgumentException(sprintf('str[]=%s is not a string', gettype($str)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY); + } elseif ((is_string($str)) && (empty($str))) { + // Entry is empty + throw new InvalidArgumentException('str is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); + } + // Convert them all $str = str_replace('-', '_', $str); @@ -3277,32 +3293,32 @@ Loaded includes: * Creates a full-qualified file name (FQFN) for given file name by adding * a configured temporary file path to it. * - * @param $fileName Name for temporary file - * @return $fqfn Full-qualified file name + * @param $infoInstance An instance of a SplFileInfo class + * @return $tempInstance An instance of a SplFileInfo class (temporary file) * @throw PathWriteProtectedException If the path in 'temp_file_path' is write-protected * @throws FileIoException If the file cannot be written */ - protected static function createTempPathForFile ($fileName) { + protected static function createTempPathForFile (SplFileInfo $infoInstance) { // Get config entry - $basePath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('temp_file_path'); + $basePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('temp_file_path'); // Is the path writeable? if (!is_writable($basePath)) { // Path is write-protected - throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); + throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); } // END - if // Add it - $fqfn = $basePath . DIRECTORY_SEPARATOR . $fileName; + $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename()); // Is it reachable? - if (!FrameworkBootstrap::isReachableFilePath($fqfn)) { + if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) { // Not reachable - throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_REACHABLE); + throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE); } // END - if // Return it - return $fqfn; + return $tempInstance; } /**