]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 10:35:21 +0000 (11:35 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 10:35:21 +0000 (11:35 +0100)
- reduced over-usage of is_string()

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/commands/html/class_HtmlLoginAreaCommand.php
framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php
framework/main/classes/template/console/class_ConsoleTemplateEngine.php
framework/main/classes/template/html/class_HtmlTemplateEngine.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/mail/class_MailTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php
framework/main/classes/utils/string/class_StringUtils.php
framework/main/middleware/debug/class_DebugMiddleware.php
framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php

index 95fac58a1918ed5ec2060b743fff40bd0943c438..834765f18ecd179444bd3581fe253e676c6b959b 100644 (file)
@@ -185,10 +185,10 @@ class HtmlLoginAreaCommand extends BaseCommand implements Commandable {
                $actReq = $requestInstance->getRequestElement('action');
 
                // Do we have a "action" parameter set?
-               if ((is_string($actReq)) && (!empty($actReq))) {
+               if (!empty($actReq)) {
                        // Then use it with prefix
                        $this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq;
-               } // END - if
+               }
 
                // Get a resolver
                $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName);
index 6816e4e4c6165f2655f1fd972da513e8cc28ae9a..a39c83a9e30f59c1cac404602449f880a7259b68 100644 (file)
@@ -12,6 +12,7 @@ use Org\Mxchange\CoreFramework\Deprecated\PathIsNoDirectoryException;
 
 // Import SPL stuff
 use \DirectoryIterator;
+use \InvalidArgumentException;
 
 /**
  * A class for directory reading and getting its contents, no recursion!
@@ -79,14 +80,11 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework
         * @throws      PathIsNoDirectoryException      If the provided path name is not valid
         * @throws      PathReadProtectedException      If the provided path name is read-protected
         */
-       public static final function createFrameworkDirectoryPointer ($pathName) {
+       public static final function createFrameworkDirectoryPointer (string $pathName) {
                // Some pre-sanity checks...
-               if (is_null($pathName)) {
-                       // No pathname given
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_string($pathName)) {
-                       // Is not a string
-                       throw new InvalidPathStringException(NULL, self::EXCEPTION_INVALID_STRING);
+               if (empty($pathName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "pathName" is empty');
                } elseif (!is_dir($pathName)) {
                        // Not a directory
                        throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME);
index 85d61d6dc5075f9744809efd4c3751c04cb8a071..309822b463b7731b4025630a979e564ba71b5df8 100644 (file)
@@ -71,9 +71,6 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index 76dac48c78cc77cfc4419b9fea3507722ff80ae2..306445215e566c4ce2339b16a7274a399ad58f29 100644 (file)
@@ -71,9 +71,6 @@ class HtmlTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index da1faf41195fe8aaae867e8b9fd5394f74a35abe..33878f8bd5820793365c4b72653d2d1b08291c08 100644 (file)
@@ -115,9 +115,6 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index 338fd7435783e14eacb4492d431e6792e0ad7014..b8b97359e47679754f8008f55c66a5348ffabac5 100644 (file)
@@ -105,9 +105,6 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index ed9468ef78b769382476e9096cedc1f14c2181e0..e9eb5d0b7a04a44a57cd31d7b02ce0533abc48fa 100644 (file)
@@ -167,9 +167,6 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new UnexpectedValueException(sprintf('[%s:%d] Variable templateBasePath is empty.', $templateInstance->__toString(), __LINE__), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new UnexpectedValueException(sprintf('[%s:%d] %s is not a string with a base path.', $templateInstance->__toString(), __LINE__, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new InvalidDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index 39026824d24d0ac83af528fe3c53e6315040045a..892bb09df652ab14c7647ce83e39118cdfa1b1fa 100644 (file)
@@ -125,9 +125,6 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi
                if (empty($templateBasePath)) {
                        // Base path is empty
                        throw new BasePathIsEmptyException($this, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-               } elseif (!is_string($templateBasePath)) {
-                       // Is not a string
-                       throw new InvalidBasePathStringException(array($this, $templateBasePath), self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($templateBasePath)) {
                        // Is not a path
                        throw new BasePathIsNoDirectoryException(array($this, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
index e6c4c738cfc6364d98b297e3cf875ab14d075e39..b114566a8a58b4db2f66bce7b67f449bdfd689f9 100644 (file)
@@ -144,17 +144,11 @@ final class StringUtils extends BaseFrameworkSystem {
         * @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, self::EXCEPTION_IS_NULL_POINTER);
-               } elseif (!is_string($str)) {
+       public static function convertDashesToUnderscores (string $str) {
+               // Validate parameter
+               if (empty($str)) {
                        // Entry is empty
-                       throw new InvalidArgumentException(sprintf('str[]=%s is not a string', gettype($str)), FrameworkConfiguration::EXCEPTION_CONFIG_KEY_IS_EMPTY);
-               } elseif ((is_string($str)) && (empty($str))) {
-                       // Entry is empty
-                       throw new InvalidArgumentException('str is empty', FrameworkConfiguration::EXCEPTION_CONFIG_KEY_IS_EMPTY);
+                       throw new InvalidArgumentException('Parameter "str" is empty');
                }
 
                // Convert them all
index 0d91375463355534266ab25da95a6d059e8a305a..6a951abb1929faf7c67effbbbd976b3a4a77426b 100644 (file)
@@ -80,7 +80,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
 
                        // All fine
                        $isInitialized = true;
-               } elseif ((!is_null($outputClass)) && (is_string($outputClass)) && (class_exists($outputClass))) {
+               } elseif (class_exists($outputClass)) {
                        // A name for a debug output class has been provided so we try to get it
                        $outputInstance = ObjectFactory::createObjectByName($outputClass);
 
index 1dd976658fd181e8ba6fa9e412a30864ec5014ce..1ca262eb7a8abc9914da8c88701785c91cdea22c 100644 (file)
@@ -85,9 +85,9 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
                        // This may throw exceptions
                        try {
                                // Is the config entry valid and class is there?
-                               if (!is_string($configKey)) {
+                               if (!is_string($configValue)) {
                                        // Is not a string
-                                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configKey=%s has unexpected type "%s". FAILED', $configKey, gettype($configKey)));
+                                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configValue=%s has unexpected type "%s". FAILED', $configValue, gettype($configValue)));
 
                                        // Skip further tests
                                        $failed++;