Skip to content

Commit

Permalink
Add phpdocs, fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jun 19, 2012
1 parent 8e31c7d commit 128ef08
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
*
* The conversion can consists in mere filtering, but it is also possible to
* do lookups, or give back specific objects.
*
* @author David de Boer <david@ddeboer.nl>
*/
interface Converter
{
/**
* Convert a value
*
* @param mixed $input Input value
*
* @return mixed
*/
function convert($input);
Expand Down
3 changes: 3 additions & 0 deletions Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Ddeboer\DataImportBundle;

/**
* A filter decides whether an item is accepted into the import workflow
*/
interface Filter
{
/**
Expand Down
41 changes: 31 additions & 10 deletions Reader/ExcelReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
*
* PHPExcel must be installed.
*
* @link http://phpexcel.codeplex.com/
* @link https://github.com/logiQ/PHPExcel
*
* @author David de Boer <david@ddeboer.nl>
* @link http://phpexcel.codeplex.com/
* @link https://github.com/logiQ/PHPExcel
*/
class ExcelReader implements Reader
{
Expand All @@ -24,10 +23,10 @@ class ExcelReader implements Reader
/**
* Construct CSV reader
*
* @param Source | \SplFileObject The source: can be either a source or
* file object
* @param int $headerRowNumber Optional number of header row
*
* @param Source|\SplFileObject $source The source: can be either a
* source or file object
* @param int $headerRowNumber Optional number of header
* row
*/
public function __construct($source, $headerRowNumber = null)
{
Expand Down Expand Up @@ -82,11 +81,13 @@ public function getColumnHeaders()
* Set column headers
*
* @param array $columnHeaders
* @return CsvReader
*
* @return $this
*/
public function setColumnHeaders(array $columnHeaders)
{
$this->columnHeaders = $columnHeaders;

return $this;
}

Expand All @@ -111,12 +112,14 @@ public function rewind()
* Set header row number
*
* @param int $rowNumber Number of the row that contains column header names
* @return CsvReader
*
* @return $this
*/
public function setHeaderRowNumber($rowNumber)
{
$this->headerRowNumber = $rowNumber;
$this->columnHeaders = $this->worksheet[$rowNumber];

return $this;
}

Expand All @@ -141,29 +144,45 @@ public function countRows()
foreach ($this as $row) {
$rows++;
}

return $rows;
}

/**
* {@inheritdoc}
*/
public function next()
{
$this->pointer++;
}

/**
* {@inheritdoc}
*/
public function valid()
{
return isset($this->worksheet[$this->pointer]);
}

/**
* {@inheritdoc}
*/
public function key()
{
return $this->pointer;
}

/**
* {@inheritdoc}
*/
public function seek($pointer)
{
$this->pointer = $pointer;
}

/**
* {@inheritdoc}
*/
public function getFields()
{
return $this->columnHeaders;
Expand All @@ -172,12 +191,14 @@ public function getFields()
/**
* Get a row
*
* @param int $number Row number
* @param int $number Row number
*
* @return array
*/
public function getRow($number)
{
$this->seek($number);

return $this->current();
}
}
4 changes: 2 additions & 2 deletions Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Writer
* @return Writer
*/
function prepare();

/**
* Write one data item
*
Expand All @@ -25,7 +25,7 @@ function prepare();
* @return Writer
*/
function writeItem(array $item, array $originalItem = array());

/**
* Wrap up the writer after all items have been written
*
Expand Down

0 comments on commit 128ef08

Please sign in to comment.