X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Ffile_directories%2Finput%2Ftext%2Fclass_FrameworkTextFileInputPointer.php;h=642e555fef2a9d2454019e0875ed2668b5c1d1af;hb=9aafc2b0b062e10d0fa5d61bfb551938fcf422e2;hp=1b3c88eee1a338a85763a67f16b5a8770648f370;hpb=4f9cf34b521892cb99fae9b21b92787f3d555b74;p=core.git diff --git a/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php b/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php index 1b3c88ee..642e555f 100644 --- a/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php +++ b/framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php @@ -12,12 +12,15 @@ use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; +// Import SPL stuff +use \SplFileInfo; + /** * A class for reading text files * * @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 - 2020 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -54,7 +57,8 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * @throws FileReadProtectedException If the file cannot be read from * @return void */ - public static final function createFrameworkTextFileInputPointer ($infoInstance) { + public static final function createFrameworkTextFileInputPointer (SplFileInfo $infoInstance) { + // Check parameter if (!FrameworkBootstrap::isReachableFilePath($infoInstance)) { // File cannot be reached throw new FileIoException($infoInstance, self::EXCEPTION_FILE_NOT_REACHABLE); @@ -68,6 +72,11 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { // Try to open a handler $fileObject = $infoInstance->openFile('r'); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEXT-FILE-INPUT: fileObject[]=' . gettype($fileObject)); + + // Is it valid? if ((is_null($fileObject)) || ($fileObject === false)) { // Something bad happend throw new FileIoException($infoInstance, self::EXCEPTION_FILE_POINTER_INVALID); @@ -77,7 +86,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { $pointerInstance = new FrameworkTextFileInputPointer(); // Set file pointer and file name - $pointerInstance->setPointer($fileObject); + $pointerInstance->setFileObject($fileObject); // Return the instance return $pointerInstance; @@ -108,10 +117,10 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { * * @param $bytes Amount of bytes to read or whole line (only text files) * @return $data Data read from file - * @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 InvalidResourceException If there is no object being set */ - public function read ($bytes = NULL) { + public function read (int $bytes = NULL) { // Some sanity checks if (is_null($this->getFileObject())) { // Pointer not initialized