X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Ffile_directories%2Ftext%2Foutput%2Fclass_BaseOutputTextFile.php;h=52fce508347867abfd025dda6c3ec62f8fba9081;hp=30212999244066aa58eaf965f39e48ddc653f06f;hb=HEAD;hpb=a60894f1d6ef33613d2d0351075aa07aa257f304 diff --git a/framework/main/classes/file_directories/text/output/class_BaseOutputTextFile.php b/framework/main/classes/file_directories/text/output/class_BaseOutputTextFile.php index 30212999..ba85de96 100644 --- a/framework/main/classes/file_directories/text/output/class_BaseOutputTextFile.php +++ b/framework/main/classes/file_directories/text/output/class_BaseOutputTextFile.php @@ -3,8 +3,9 @@ namespace Org\Mxchange\CoreFramework\Filesystem\Text; // Import framework stuff -use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile; +use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Output\BaseOutput; /** @@ -12,7 +13,7 @@ use Org\Mxchange\CoreFramework\Output\BaseOutput; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -36,7 +37,7 @@ abstract class BaseOutputTextFile extends BaseAbstractFile { * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct (string $className) { // Call parent constructor parent::__construct($className); } @@ -46,13 +47,25 @@ abstract class BaseOutputTextFile extends BaseAbstractFile { * * @param $fileName File's name * @return void + * @throws InvalidArgumentException If a parameter has an invalid value */ - protected function initFile ($fileName) { + protected function initFile (string $fileName) { + // Check parameter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-OUTPUT-TEXT-FILE: fileName=%s - CALLED!', $fileName)); + if (empty($fileName)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "fileName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } + // Get a file i/o pointer instance - $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', array($fileName)); + $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', [$fileName]); // ... and set it here + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-OUTPUT-TEXT-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString())); $this->setPointerInstance($pointerInstance); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-OUTPUT-TEXT-FILE: EXIT!'); } }