From 4454196b4c9190446cc99fff05fe86cdcd93facc Mon Sep 17 00:00:00 2001 From: William Knauss Date: Wed, 5 Feb 2014 18:31:27 -0500 Subject: [PATCH] parse readability --- parsecsv.lib.php | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/parsecsv.lib.php b/parsecsv.lib.php index 967e143..d389b7b 100644 --- a/parsecsv.lib.php +++ b/parsecsv.lib.php @@ -206,20 +206,37 @@ class parseCSV { * @param input CSV file or string * @return nothing */ - function parse ($input = null, $offset = null, $limit = null, $conditions = null) { - if ( $input === null ) $input = $this->file; - if ( !empty($input) ) { - if ( $offset !== null ) $this->offset = $offset; - if ( $limit !== null ) $this->limit = $limit; - if ( count($conditions) > 0 ) $this->conditions = $conditions; - if ( is_readable($input) ) { + public function parse ($input = null, $offset = null, $limit = null, $conditions = null) { + if ($input===null) { + $input = $this->file; + } + + if (!empty($input)) { + if ($offset!==null) { + $this->offset = $offset; + } + + if ($limit!==null) { + $this->limit = $limit; + } + + if (count($conditions)>0) { + $this->conditions = $conditions; + } + + if (is_readable($input)) { $this->data = $this->parse_file($input); - } else { + } + else { $this->file_data = &$input; $this->data = $this->parse_string(); } - if ( $this->data === false ) return false; + + if ($this->data===false) { + return false; + } } + return true; }