Ejemplo n.º 1
0
<?php

$filePath = __DIR__ . '/example_read.txt';
use Naucon\File\FileReader;
$fileObject = new FileReader($filePath, 'r', true);
echo 'File: ' . $fileObject->getPathname();
echo '<br/>';
echo '<br/>';
echo 'Iterate lines:<br/>';
// iterate
foreach ($fileObject as $line) {
    echo $line . '<br/>';
}
echo '<br/>';
echo '<br/>';
// while
echo 'While:<br/>';
echo $fileObject->firstLine();
echo '<br/>';
while (!$fileObject->isLast()) {
    echo $fileObject->nextLine();
    echo '<br/>';
}
echo '<br/>';
echo '<br/>';
echo 'Navigate:<br/>';
echo $fileObject->firstLine();
echo '<br/>';
echo $fileObject->nextLine();
echo '<br/>';
echo $fileObject->nextLine();
Ejemplo n.º 2
0
 /**
  * @depends     testInit
  * @return      void
  */
 public function testReadLines()
 {
     $filePath = __DIR__ . '/example_read.txt';
     $fileObject = new FileReader($filePath, 'r', true);
     $expectedArray = array('Line01', 'Line02', 'Line03', 'Line04', 'Line05', 'Line06', 'Line07', 'Line08', 'Line09');
     $this->assertEquals($expectedArray, $fileObject->readLines());
 }