Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 41 additions & 13 deletions class.csv.php → Document.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
<?php
/**
* The CSV class creates and reads CSV Files
*
* PHP version 7.0.0
*
* @category Data Storage and Manipulation
* @package Module/CSV
* @author Jaime Rodriguez <hi.i.am.jaime@gmail.com>
* @license https://opensource.org/licenses/MIT MIT
* @version GIT: 1.0.0
* @link http://sleepymustache.com
*/

namespace Module\CSV;

use Sleepy\Core\Hook;
use Sleepy\Core\Module;

/**
* Creates a Comma Separated Value file.
*
* ### Usage
*
* <code>
* // loads a existing CSV file
* $c = new \Module\CSV\Document('presidents.csv');
*
* $c->add(array(
* 'George',
* 'Washington'
* ));
*
* use \Module\CSV\Document;
*
* // Load a file
* $c = new Document('presidents.csv');
*
* // Add a entry, then save.
* $c->add(['George', 'Washington']);
* $c->save();
* </code>
*
* ### Changelog
*
* ##Version 2.0
* * Made compatible with 2.x branch
*
* ##Version 1.9
* * Added ability to use your own filename in the show method
Expand All @@ -35,12 +53,19 @@
* * check if we can remove the header before doing it... teamsite issue.
* * suppress flock warnings... teamsite issue
*
* @date August 13, 2014
* @author Jaime A. Rodriguez <hi.i.am.jaime@gmail.com>
* @version 1.8
* @license http://opensource.org/licenses/MIT
* @category Data Storage and Manipulation
* @package Module/Performance
* @author Jaime Rodriguez <hi.i.am.jaime@gmail.com>
* @license https://opensource.org/licenses/MIT MIT
* @link http://sleepymustache.com
*/
class Document {
class Document extends Module
{
/**
* Define the hook points
*/
public $hooks = [];

/**
* string The filename of the CSV file
*/
Expand Down Expand Up @@ -262,3 +287,6 @@ public function show() {
$this->save();
}
}


Hook::register(new Document());
3 changes: 3 additions & 0 deletions csv_test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
// @todo update tests to PHPUnit
die();

require_once('class.csv.php');

/**
Expand Down