]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php
Continued:
[core.git] / framework / main / classes / file_directories / directory / class_FrameworkDirectoryPointer.php
index 23d3b6a97d7ff884108456e92afe4e9d1396b5bc..7eb73dfa310e06d0a3c8266350b82a3ce5b9f298 100644 (file)
@@ -12,13 +12,14 @@ use Org\Mxchange\CoreFramework\Deprecated\PathIsNoDirectoryException;
 
 // Import SPL stuff
 use \DirectoryIterator;
+use \InvalidArgumentException;
 
 /**
  * A class for directory reading and getting its contents, no recursion!
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -49,7 +50,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework
        /**
         * Protected constructor
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -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);
@@ -137,7 +135,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework
         * @param       $except         Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored
         * @return      SplFileInfo             An instance of a SplFileInfo class
         */
-       public function readDirectoryExcept (array $except = array()) {
+       public function readDirectoryExcept (array $except = []) {
                // No exceptions given?
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DIRECTORY-POINTER: except()=%d - CALLED!', count($except)));
                if (count($except) == 0) {
@@ -232,8 +230,7 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem implements Framework
         * @param       $pathName       The new path name
         * @return      void
         */
-       protected final function setPathName ($pathName) {
-               $pathName = (string) $pathName;
+       protected final function setPathName (string $pathName) {
                $this->pathName = $pathName;
        }