]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
Continued:
[core.git] / framework / main / classes / file_directories / input / text / class_FrameworkTextFileInputPointer.php
index d113df5d07fe70d6352899445d8385c3f2b50acf..1805d7c8c5338601537fc79b985451aa1b115710 100644 (file)
@@ -62,7 +62,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         */
        public static final function createFrameworkTextFileInputPointer (SplFileInfo $fileInstance) {
                // Check parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance->__toString()));
                if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
                        // File cannot be reached
                        throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
@@ -78,7 +78,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
                $fileObject = $fileInstance->openFile('r');
 
                // Is it valid?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TEXT-FILE-INPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
                if (!($fileObject instanceof SplFileObject)) {
                        // Something bad happend
                        throw new FileIoException($fileInstance, self::EXCEPTION_FILE_POINTER_INVALID);
@@ -91,7 +91,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEXT-FILE-INPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
@@ -102,6 +102,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         */
        public function readFromFile () {
                // Read 1024 Byte data from the file pointer and return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
                return $this->read(1024);
        }
 
@@ -112,6 +113,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         */
        public function readLine () {
                // Read whole line from the file pointer and return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: CALLED!');
                return $this->read();
        }
 
@@ -126,12 +128,13 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         */
        public function read (int $bytes = 0) {
                // Some sanity checks
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: bytes=%d - CALLED!', $bytes));
                if ($bytes < 0) {
                        // Cannot be below zero
                        throw new OutOfBoundsException(sprintf('bytes=%d is not valid', $bytes));
                } elseif (is_null($this->getFileObject())) {
                        // Pointer not initialized
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+                       throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_object($this->getFileObject())) {
                        // Pointer is not a valid resource!
                        throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())), FrameworkInterface::EXCEPTION_LOGIC_EXCEPTION);
@@ -140,13 +143,16 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
                // Is $bytes set?
                if ($bytes > 0) {
                        // Try to read given characters
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fread(%d) ...', $bytes));
                        $data = $this->getFileObject()->fread($bytes);
                } else {
                        // Try to read whole line
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('RAW-FILE-INPUT-POINTER: Invoking this->fileObject->fgets() ...');
                        $data = $this->getFileObject()->fgets();
                }
 
                // Then return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('RAW-FILE-INPUT-POINTER: data()=%d - EXIT!', strlen($data)));
                return $data;
        }