// 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
*
/**
* Protected constructor
*/
- protected function __construct () {
+ private function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
}
* @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);
* @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) {
* @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;
}