8000 GitHub - victormech/ditesto: Object Oriented library to manipulate text files with PHP
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

victormech/ditesto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiTesto

Build Status Scrutinizer Code Quality Code Coverage Codacy Badge Latest Stable Version

A simple Object Oriented library to load and manipulate text files. Made using only PHP.

PHP minimum version: 7

Usage

$file = '/home/user/text-file.txt';
$fileSystem = new FileSystemHandler($file);
$textFile = new TextFile($file); 

(new FileReader($textFile, $fileSystem))->readFile();
echo $textFile; // prints all file content

You can iterate line per line if you want:

$textFile = new TextFile($file); 
$fileSystem = new FileSystemHandler($file);
(new FileReader($textFile, $fileSystem))->readFile());

foreach ($textFile as $line) {
   echo $line;
}

Or even like an Array:

$textFile[] = new Line('Adding a new line');
$textFile[0] = new Line('Changing an existent line');
echo count($textFile); // prints total of lines
echo $textFile[1]; // prints only the second line 

To persist the file changes:

$textFile = new TextFile($file); 
$fileSystem = new FileSystemHandler($file);
(new FileWriter($textFile, $fileSystem))->writeFile();

License

The MIT License (MIT). Please see License File for more information.

About

Object Oriented library to manipulate text files with PHP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages

0