Continued:
[core.git] / framework / main / classes / file_directories / text / output / class_BaseOutputTextFile.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Filesystem\Text;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
7 use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
8 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
9 use Org\Mxchange\CoreFramework\Output\BaseOutput;
10
11 /**
12  * A general text file class
13  *
14  * @author              Roland Haeder <webmaster@ship-simu.org>
15  * @version             0.0.0
16  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
17  * @license             GNU GPL 3.0 or any newer version
18  * @link                http://www.ship-simu.org
19  *
20  * This program is free software: you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation, either version 3 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
32  */
33 abstract class BaseOutputTextFile extends BaseAbstractFile {
34         /**
35          * Protected constructor
36          *
37          * @param       $className      Name of the class
38          * @return      void
39          */
40         protected function __construct (string $className) {
41                 // Call parent constructor
42                 parent::__construct($className);
43         }
44
45         /**
46          * Initializes this text file for reading
47          *
48          * @param       $fileName       File's name
49          * @return      void
50          * @throws      InvalidArgumentException        If a parameter has an invalid value
51          */
52         protected function initFile (string $fileName) {
53                 // Check parameter
54                 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-OUTPUT-TEXT-FILE: fileName=%s - CALLED!', $fileName));
55                 if (empty($fileName)) {
56                         // Throw IAE
57                         throw new InvalidArgumentException('Parameter "fileName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
58                 }
59
60                 // Get a file i/o pointer instance
61                 $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', [$fileName]);
62
63                 // ... and set it here
64                 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('BASE-OUTPUT-TEXT-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
65                 $this->setPointerInstance($pointerInstance);
66
67                 // Trace message
68                 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-OUTPUT-TEXT-FILE: EXIT!');
69         }
70
71 }