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
18 changes: 9 additions & 9 deletions src/CsvHeaderParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
*/
class CsvHeaderParser
{
private $aliases = [];
private $skipper = '%';
protected $aliases = [];
protected $skipper = '%';

private $table;
private $key;
private $name;
protected $table;
protected $key;
protected $name;

private $parsedHeader = [];
protected $parsedHeader = [];

/**
* Set the tablename
Expand Down Expand Up @@ -61,7 +61,7 @@ public function parseHeader( $header )
*
* @return void
*/
private function aliasColumns()
protected function aliasColumns()
{
if( empty($this->aliases) ) return;

Expand All @@ -77,7 +77,7 @@ private function aliasColumns()
*
* @return void
*/
private function skipColumns()
protected function skipColumns()
{
if( ! isset($this->skipper) ) return;

Expand All @@ -89,7 +89,7 @@ private function skipColumns()
*
* @return void
*/
private function checkColumns()
protected function checkColumns()
{
if( ! in_array($this->name, $this->table) ) unset($this->parsedHeader[$this->key]);
}
Expand Down
44 changes: 22 additions & 22 deletions src/CsvRowParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
*/
class CsvRowParser
{
private $header;
private $empty = FALSE;
private $defaults = [];
private $timestamps = TRUE;
private $parsers = [];
private $hashable = ['password'];
private $validate = [];
private $encode = TRUE;

private $key;
private $value;
private $row;
private $parsedRow;
protected $header;
protected $empty = FALSE;
protected $defaults = [];
protected $timestamps = TRUE;
protected $parsers = [];
protected $hashable = ['password'];
protected $validate = [];
protected $encode = TRUE;

protected $key;
protected $value;
protected $row;
protected $parsedRow;

/**
* Set the header and possible options to add or parse a row
Expand Down Expand Up @@ -100,7 +100,7 @@ public function parseRow( $row )
*
* @return void
*/
private function mergeRowAndHeader( )
protected function mergeRowAndHeader( )
{
foreach( $this->header as $key => $value )
{
Expand All @@ -115,7 +115,7 @@ private function mergeRowAndHeader( )
*
* @return void
*/
private function init()
protected function init()
{
$this->parsedRow = [];
}
Expand All @@ -125,7 +125,7 @@ private function init()
*
* @return void
*/
private function doValidate()
protected function doValidate()
{
if( empty($this->validate) ) return TRUE;

Expand All @@ -141,7 +141,7 @@ private function doValidate()
*
* @return void
*/
private function isEmptyValue()
protected function isEmptyValue()
{
if( $this->empty === FALSE and $this->value === '' ) $this->value = NULL;

Expand All @@ -157,7 +157,7 @@ private function isEmptyValue()
*
* @return void
*/
private function doParse()
protected function doParse()
{

if( empty($this->parsers) ) return;
Expand All @@ -176,7 +176,7 @@ private function doParse()
*
* @return void
*/
private function doEncode()
protected function doEncode()
{
if( $this->encode === FALSE ) return;

Expand All @@ -188,7 +188,7 @@ private function doEncode()
*
* @return void
*/
private function doHashable()
protected function doHashable()
{
if( empty($this->hashable) ) return;

Expand All @@ -202,7 +202,7 @@ private function doHashable()
*
* @return void
*/
private function addDefaults()
protected function addDefaults()
{
if( empty($this->defaults) ) return;

Expand All @@ -219,7 +219,7 @@ private function addDefaults()
*
* @return void
*/
private function addTimestamps()
protected function addTimestamps()
{
if( empty($this->timestamps) ) return;

Expand Down
46 changes: 23 additions & 23 deletions src/CsvSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ class CsvSeeder extends Seeder
public $encode = TRUE;


private $filepath;
private $csvData;
private $parsedData;
private $count = 0;
private $total = 0;
protected $filepath;
protected $csvData;
protected $parsedData;
protected $count = 0;
protected $total = 0;

/**
* Run the class
Expand All @@ -200,7 +200,7 @@ public function run()
*
* @return void
*/
private function setConnection()
protected function setConnection()
{
if ($this->connection !== NULL) return;

Expand All @@ -213,7 +213,7 @@ private function setConnection()
*
* @return boolean
*/
private function checkFile()
protected function checkFile()
{
if( $this->file ) return TRUE;

Expand All @@ -227,7 +227,7 @@ private function checkFile()
*
* @return boolean
*/
private function checkFilepath()
protected function checkFilepath()
{
$this->filepath = $this->file;

Expand All @@ -247,7 +247,7 @@ private function checkFilepath()
*
* @return boolean
*/
private function checkTablename()
protected function checkTablename()
{
if( ! isset($this->tablename) )
{
Expand All @@ -268,7 +268,7 @@ private function checkTablename()
*
* @return void
*/
private function seeding()
protected function seeding()
{
$this->truncateTable();

Expand All @@ -294,7 +294,7 @@ private function seeding()
*
* @return void
*/
private function truncateTable()
protected function truncateTable()
{
if( $this->truncate === FALSE ) return;

Expand All @@ -310,7 +310,7 @@ private function truncateTable()
*
* @param boolean $mode
*/
private function toggleForeignKeyCheck( $mode )
protected function toggleForeignKeyCheck( $mode )
{
if( $this->foreignKeyCheck === FALSE ) return;

Expand All @@ -330,7 +330,7 @@ private function toggleForeignKeyCheck( $mode )
*
* @return void
*/
private function setTotal()
protected function setTotal()
{
$file = file( $this->filepath, FILE_SKIP_EMPTY_LINES );

Expand All @@ -344,7 +344,7 @@ private function setTotal()
*
* @return void
*/
private function openCSV()
protected function openCSV()
{
$this->csvData = fopen( $this->filepath, 'r' );;
}
Expand All @@ -354,7 +354,7 @@ private function openCSV()
*
* @return void
*/
private function setHeader()
protected function setHeader()
{
if( $this->header == FALSE ) return;

Expand All @@ -369,7 +369,7 @@ private function setHeader()
*
* @return void
*/
private function setMapping()
protected function setMapping()
{
if( empty($this->mapping) ) return;

Expand All @@ -381,7 +381,7 @@ private function setMapping()
*
* @return void
*/
private function parseHeader()
protected function parseHeader()
{
if( empty($this->header) ) return $this->console( 'No CSV headers were parsed' );

Expand All @@ -395,7 +395,7 @@ private function parseHeader()
*
* @return void
*/
private function parseCSV()
protected function parseCSV()
{
if( ! $this->csvData || empty($this->header) ) return;

Expand Down Expand Up @@ -428,7 +428,7 @@ private function parseCSV()
*
* @return void
*/
private function insertRows()
protected function insertRows()
{
if( empty($this->parsedData) ) return;

Expand All @@ -455,7 +455,7 @@ private function insertRows()
*
* @return void
*/
private function closeCSV()
protected function closeCSV()
{
if( ! $this->csvData ) return;

Expand All @@ -467,7 +467,7 @@ private function closeCSV()
*
* @return void
*/
private function outputParsed()
protected function outputParsed()
{
$this->console( $this->count.' of '.$this->total.' rows has been seeded in table "'.$this->tablename.'"' );
}
Expand All @@ -478,7 +478,7 @@ private function outputParsed()
* @param [type] $string
* @return string
*/
private function stripUtf8Bom( $string )
protected function stripUtf8Bom( $string )
{
$bom = pack('H*', 'EFBBBF');
$string = preg_replace("/^$bom/", '', $string);
Expand All @@ -493,7 +493,7 @@ private function stripUtf8Bom( $string )
* @param string $level
* @return void
*/
private function console( $message, $level = FALSE )
protected function console( $message, $level = FALSE )
{
if (isset($this->command) === FALSE) return;

Expand Down