Rewrites:
authorRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 18:51:58 +0000 (20:51 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 13 Aug 2017 18:51:58 +0000 (20:51 +0200)
- *IsEmptyException are all superflous as also NPE and IAE can do the same and
  much more generic
- closed TODO to remove inConstructor, was bad code style anyway

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php
framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php
framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
framework/main/classes/language/class_LanguageSystem.php
framework/main/exceptions/config/class_ConfigEntryIsEmptyException.php
framework/main/exceptions/database/local_file/class_SavePathIsEmptyException.php
framework/main/exceptions/file_directory/class_FileIsEmptyException.php
framework/main/exceptions/file_directory/class_PathIsEmptyException.php
framework/main/exceptions/language/class_LanguagePathIsEmptyException.php

index f88b8d36fe5732c3bda6a80144c5dab92d2236fb..721e4ec52556f44fd7924358be9a83ba200167ee 100644 (file)
@@ -50,6 +50,7 @@ use CoreFramework\Visitor\Visitor;
 
 // Import SPL stuff
 use \stdClass;
+use \InvalidArgumentException;
 use \Iterator;
 use \ReflectionClass;
 use \SplFileInfo;
index 64688af7ab1d674bff4d0da15e7a32a94dcf7ea3..5dfb15cb9ae6224fb34a0ccfe1484db81834dbc8 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Filesytem\Pointer;
 
 // Import framework stuff
 use CoreFramework\Filesystem\FrameworkDirectory;
+use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Object\BaseFrameworkSystem;
 
 // Import SPL stuff
@@ -69,44 +70,26 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework
         * be verified here.
         *
         * @param       $pathName               The path name we shall pass to opendir()
-        * @param       $inConstructor  If we are in de/con-structor or from somewhere else
         * @return      $pointerInstance        A prepared instance of FrameworkDirectoryPointer
-        * @throws      PathIsEmptyException    If the provided path name is empty
+        * @throws      NullPointerException    If the provided path name is null
         * @throws      InvalidPathStringException      If the provided path name is not a string
         * @throws      PathIsNoDirectoryException      If the provided path name is not valid
         * @throws      PathReadProtectedException      If the provided path name is read-protected
-        * @todo        Get rid of inConstructor, could be old-lost code.
         */
-       public static final function createFrameworkDirectoryPointer ($pathName, $inConstructor = false) {
+       public static final function createFrameworkDirectoryPointer ($pathName) {
                // Some pre-sanity checks...
                if (is_null($pathName)) {
                        // No pathname given
-                       if ($inConstructor) {
-                               return NULL;
-                       } else {
-                               throw new PathIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-                       }
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_string($pathName)) {
                        // Is not a string
-                       if ($inConstructor) {
-                               return NULL;
-                       } else {
-                               throw new InvalidPathStringException(NULL, self::EXCEPTION_INVALID_STRING);
-                       }
+                       throw new InvalidPathStringException(NULL, self::EXCEPTION_INVALID_STRING);
                } elseif (!is_dir($pathName)) {
                        // Not a directory
-                       if ($inConstructor) {
-                               return NULL;
-                       } else {
-                               throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME);
-                       }
+                       throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME);
                } elseif (!is_readable($pathName)) {
                        // Not readable
-                       if ($inConstructor) {
-                               return NULL;
-                       } else {
-                               throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH);
-                       }
+                       throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH);
                }
 
                // Create new instance
index 0fdd4398c37e314326defec5d958b5db45d8964d..50c21f6c5b4b0e0f0b27cec871b0cd911663c21b 100644 (file)
@@ -50,7 +50,6 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         * be verified here.
         *
         * @param       $fileName       The file name we shall pass to fopen()
-        * @throws      FileIsEmptyException            If the provided file name is empty.
         * @throws      FileIoException                         If the file is not reachable
         * @throws      FileReadProtectedException      If the file cannot be read from
         * @return      void
index a63535c69616164b422eb34c3f927c540f98b705..30189ba7a4d0e9361ca6397c9b689687a25379b7 100644 (file)
@@ -8,6 +8,7 @@ use CoreFramework\Filesystem\Pointer\OutputPointer;
 use CoreFramework\Generic\NullPointerException;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \SplFileInfo;
 
 /**
@@ -49,22 +50,22 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $infoInstance   An instance of a SplFileInfo class
         * @param       $mode           The output mode ('w', 'a' are valid)
-        * @throws      FileIsEmptyException    If the provided file name is empty.
+        * @throws      InvalidArgumentException        If parameter mode is empty
         * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
        public static final function createFrameworkRawFileOutputPointer (SplFileInfo $infoInstance, $mode) {
                // Some pre-sanity checks...
-               if (is_null($infoInstance)) {
+               if (is_null($mode)) {
                        // No infoInstance given
-                       throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new InvalidArgumentException('Parameter "mode" is empty');
                } // END - if
 
                // Try to open a handler
                $fileObject = $infoInstance->openFile($mode);
                if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException ($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
index 425c57d96e2062e8e01558def4f2c27b1329f78d..dde389fb12871b1550a828dc2a492fc169f0ff70 100644 (file)
@@ -9,6 +9,7 @@ use CoreFramework\Generic\NullPointerException;
 use CoreFramework\Generic\UnsupportedOperationException;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \SplFileInfo;
 
 /**
@@ -50,22 +51,24 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $fileInstance   An instance of a SplFileInfo class
         * @param       $mode           The output mode ('w', 'a' are valid)
-        * @throws      FileIsEmptyException    If the provided file name is empty.
+        * @throws      InvalidArgumentException        If mode is empty
         * @throws      FileIoException                 If fopen() returns not a file resource
         * @return      void
         */
        public static final function createFrameworkTextFileOutputPointer (SplFileInfo $fileInstance, $mode) {
                // Some pre-sanity checks...
-               if (is_null($fileInstance)) {
+               if (empty($mode)) {
                        // No filename given
-                       throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new InvalidArgumentException('Parameter "mode" is empty');
                } // END - if
 
                // Try to open a handler
                $fileObject = $fileInstance->openFile($mode);
+
+               // Is it valid?
                if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
-                       throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
+                       throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
                } // END - if
 
                // Create new instance
index 657c113742c318d73d86263a18e5e852a6947792..89e299172b1ba9bca3441b134146646aeb93c73e 100644 (file)
@@ -8,6 +8,9 @@ use CoreFramework\Object\BaseFrameworkSystem;
 use CoreFramework\Registry\Registerable;
 use CoreFramework\Registry\Registry;
 
+// Import SPL stuff
+use \InvalidArgumentException;
+
 /**
  * The language sub-system for handling language strings being used in the
  * application and whole framework
@@ -67,7 +70,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
         *
         * @param       $languageBasePath       The local base path for all language strings or emty for auto-detection
         * @return      $langInstance   An instance of LanguageSystem
-        * @throws      LanguagePathIsEmptyException    If the provided $languageBasePath is empty
+        * @throws      InvalidArgumentException        If languageBasePath remains empty (@TODO Get rid of that old-lost code)
         * @throws      InvalidLanguagePathStringException      If $languageBasePath is no string
         * @throws      LanguagePathIsNoDirectoryException      If $languageBasePath is no
         *                                                                              directory or not found
@@ -94,7 +97,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage,
                // Is the base path valid?
                if (empty($languageBasePath)) {
                        // Language path is empty
-                       throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+                       throw new InvalidArgumentException('languageBasePath is still empty');
                } elseif (!is_string($languageBasePath)) {
                        // Is not a string
                        throw new InvalidLanguagePathStringException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING);
index fc21d8ef3a64f0be30a494e8b0329fb9df0620e3..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,49 +1,2 @@
 <?php
-// Own namespace
-namespace CoreFramework\Configuration;
-
-// Import framework stuff
-use CoreFramework\Generic\FrameworkException;
-
-/**
- * An exception thrown when a configuration entry is empty
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ConfigEntryIsEmptyException extends FrameworkException {
-       /**
-        * The constructor
-        *
-        * @param       $class  Class throwing this exception
-        * @param       $code   Code number for the exception
-        * @return      void
-        */
-       public function __construct (FrameworkConfiguration $class, $code) {
-               // Add a message around the missing class
-               $message = sprintf('[%s:%d] Empty configuration entry provided.',
-                       $class->__toString(),
-                       $this->getLine()
-               );
-
-               // Call parent constructor
-               parent::__construct($message, $code);
-       }
-
-}
+// @DEPRECATED
index 454558f1f607e59cee50bf56d34f0d709496bfde..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,51 +1,2 @@
 <?php
-// Own namespace
-namespace CoreFramework\Deprecated;
-
-// Import framework stuff
-use CoreFramework\Database\DatabaseException;
-use CoreFramework\Generic\FrameworkInterface;
-
-/**
- * An exception thrown when the save path string is empty
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- * @deprecated Please don't use this anymore.
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class SavePathIsEmptyException extends DatabaseException {
-       /**
-        * The constructor
-        *
-        * @param       $class  Class throwing this exception
-        * @param       $code   Code number for the exception
-        * @return      void
-        */
-       public function __construct (FrameworkInterface $class, $code) {
-               // Add a message around the missing class
-               $message = sprintf('[%s:%d] Save path is empty.',
-                       $class->__toString(),
-                       $this->getLine()
-               );
-
-               // Call parent constructor
-               parent::__construct($message, $code);
-       }
-
-}
+// @DEPRECATED
index 55fe201efc0306cf721e8b277ddcea2d3f867f2c..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,47 +1,2 @@
 <?php
-// Own namespace
-namespace CoreFramework\Deprecated;
-
-// Import framework stuff
-use CoreFramework\Generic\FrameworkException;
-
-// Import SPL stuff
-use \SplFileInfo;
-
-/**
- * An exception thrown when a file name is empty or NULL.
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- * @deprecated Don't use this anymore
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class FileIsEmptyException extends FrameworkException {
-       /**
-        * The constructor
-        *
-        * @param       $infoInstance   An instance of a SplFileInfo class (ignored)
-        * @param       $code   Code number for the exception
-        * @return      void
-        */
-       public function __construct (SplFileInfo $infoInstance, $code) {
-               // Call parent constructor
-               parent::__construct('No file name provided.', $code);
-       }
-
-}
+// @DEPRECATED
index 4dcd3f146a21cc72d2a21753bdb8256e76888179..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,50 +1,2 @@
 <?php
-// Own namespace
-namespace CoreFramework\Filesystem;
-
-// Import framework stuff
-use CoreFramework\Generic\FrameworkException;
-use CoreFramework\Generic\FrameworkInterface;
-
-/**
- * An exception thrown when the path string is empty
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class PathIsEmptyException extends FrameworkException {
-       /**
-        * The constructor
-        *
-        * @param       $class  Class throwing this exception
-        * @param       $code   Code number for the exception
-        * @return      void
-        */
-       public function __construct (FrameworkInterface $class, $code) {
-               // Add a message around the missing class
-               $message = sprintf('[%s:%d] Directory path is empty.',
-                       $class->__toString(),
-                       $this->getLine()
-               );
-
-               // Call parent constructor
-               parent::__construct($message, $code);
-       }
-
-}
+// @DEPRECATED
index 53e6aec58e1cd1df0dbd29e4e780966ee6cb2090..7d6dceec926b2c790d8a6cc64b29a822d57f79e9 100644 (file)
@@ -1,50 +1,2 @@
 <?php
-// Own namespace
-namespace CoreFramework\Localization;
-
-// Import framework stuff
-use CoreFramework\Generic\FrameworkException;
-use CoreFramework\Generic\FrameworkInterface;
-
-/**
- * An exception thrown when the language path string is empty
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- * 
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class LanguagePathIsEmptyException extends FrameworkException {
-       /**
-        * The constructor
-        *
-        * @param       $class  Class throwing this exception
-        * @param       $code   Code number for the exception
-        * @return      void
-        */
-       public function __construct (FrameworkInterface $class, $code) {
-               // Add a message around the missing class
-               $message = sprintf('[%s:%d] Language base path is empty.',
-                       $class->__toString(),
-                       $this->getLine()
-               );
-
-               // Call parent constructor
-               parent::__construct($message, $code);
-       }
-
-}
+// @DEPRECATED