]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
Continued:
[core.git] / framework / main / classes / file_directories / output / text / class_FrameworkTextFileOutputPointer.php
index 425c57d96e2062e8e01558def4f2c27b1329f78d..b4b8b8dadfc14bdd56f04455faa8d07b9b2075bf 100644 (file)
@@ -1,14 +1,15 @@
 <?php
 // Own namespace
-namespace CoreFramework\Filesystem\Pointer\Text;
+namespace Org\Mxchange\CoreFramework\Filesystem\Pointer\Text;
 
 // Import framework stuff
-use CoreFramework\FileSystem\BaseFileIo;
-use CoreFramework\Filesystem\Pointer\OutputPointer;
-use CoreFramework\Generic\NullPointerException;
-use CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\FileSystem\BaseFileIo;
+use Org\Mxchange\CoreFramework\Filesystem\Pointer\OutputPointer;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 
 // Import SPL stuff
+use \InvalidArgumentException;
 use \SplFileInfo;
 
 /**
@@ -16,7 +17,7 @@ use \SplFileInfo;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -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
@@ -83,10 +86,10 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         *
         * @param       $dataStream             The data stream we shall write to the file
         * @return      mixed                   Number of writes bytes or false on error
-        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      NullPointerException    If the file pointer instance is not set by setFileObject()
         * @throws      LogicException  If there is no object being set
         */
-       public function writeToFile ($dataStream) {
+       public function writeToFile (string $dataStream) {
                if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
@@ -119,7 +122,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         * @return      mixed                   Number of writes bytes or false on error
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function writeAtPosition ($seedPosition, $data) {
+       public function writeAtPosition (int $seedPosition, string $data) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }