}
// Try to open a handler
- $fileInstance = fopen($fileName, 'rb');
- if ((is_null($fileInstance)) || ($fileInstance === FALSE)) {
+ $filePointer = fopen($fileName, 'rb');
+ if ((is_null($filePointer)) || ($filePointer === FALSE)) {
// Something bad happend
throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID);
} // END - if
$pointerInstance = new FrameworkFileInputPointer();
// Set file pointer and file name
- $pointerInstance->setInstance($fileInstance);
+ $pointerInstance->setPointer($filePointer);
$pointerInstance->setFileName($fileName);
// Return the instance
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
* is not set by setPointer()
+ * @throws InvalidResourceException If there is being set
*/
public function readFromFile () {
- if (!$this->getInstance() instanceof SplFileObject) {
+ if (is_null($this->getPointer())) {
// Pointer not initialized
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } elseif (!is_resource($this->getPointer())) {
+ // Pointer is not a valid resource!
+ throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
}
// Read data from the file pointer and return it
- return fread($this->getInstance(), 1024);
+ return fread($this->getPointer(), 1024);
}
}