Fix code style

This commit is contained in:
Adrien Loison committed 2017-09-06 00:33:43 +02:00
1 parent 740fcfb8c1
commit b968513cb9
171 files changed
+517 -792

No files matched your search

@@ -13,8 +13,6 @@ use Box\Spout\Reader\CSV\SheetIterator;
/**
* Class EntityFactory
* Factory to create entities
*
* @package Box\Spout\Reader\CSV\Creator
*/
class EntityFactory implements EntityFactoryInterface
{
@@ -61,6 +59,7 @@ class EntityFactory implements EntityFactoryInterface
private function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper)
{
$encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper);
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper);
}
}
@@ -9,13 +9,11 @@ use Box\Spout\Reader\Common\Entity\Options;
/**
* Class OptionsManager
* CSV Reader options manager
*
* @package Box\Spout\Reader\CSV\Manager
*/
class OptionsManager extends OptionsManagerAbstract
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getSupportedOptions()
{
@@ -29,7 +27,7 @@ class OptionsManager extends OptionsManagerAbstract
}
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function setDefaultOptions()
{
+5 -5
View File
@@ -2,16 +2,14 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\ReaderAbstract;
use Box\Spout\Common\Exception\IOException;
/**
* Class Reader
* This class provides support to read data from a CSV file.
*
* @package Box\Spout\Reader\CSV
*/
class Reader extends ReaderAbstract
{
@@ -34,6 +32,7 @@ class Reader extends ReaderAbstract
public function setFieldDelimiter($fieldDelimiter)
{
$this->optionsManager->setOption(Options::FIELD_DELIMITER, $fieldDelimiter);
return $this;
}
@@ -47,6 +46,7 @@ class Reader extends ReaderAbstract
public function setFieldEnclosure($fieldEnclosure)
{
$this->optionsManager->setOption(Options::FIELD_ENCLOSURE, $fieldEnclosure);
return $this;
}
@@ -60,6 +60,7 @@ class Reader extends ReaderAbstract
public function setEncoding($encoding)
{
$this->optionsManager->setOption(Options::ENCODING, $encoding);
return $this;
}
@@ -78,8 +79,8 @@ class Reader extends ReaderAbstract
* If setEncoding() was not called, it assumes that the file is encoded in UTF-8.
*
* @param string $filePath Path of the CSV file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException
* @return void
*/
protected function openReader($filePath)
{
@@ -111,7 +112,6 @@ class Reader extends ReaderAbstract
return $this->sheetIterator;
}
/**
* Closes the reader. To be used after reading the file.
*
+12 -16
View File
@@ -2,17 +2,13 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Common\Helper\EncodingHelper;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\IteratorInterface;
/**
* Class RowIterator
* Iterate over CSV rows.
*
* @package Box\Spout\Reader\CSV
*/
class RowIterator implements IteratorInterface
{
@@ -28,7 +24,7 @@ class RowIterator implements IteratorInterface
protected $numReadRows = 0;
/** @var array|null Buffer used to store the row data, while checking if there are more rows to read */
protected $rowDataBuffer = null;
protected $rowDataBuffer;
/** @var bool Indicates whether all rows have been read */
protected $hasReachedEndOfFile = false;
@@ -70,7 +66,7 @@ class RowIterator implements IteratorInterface
/**
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @see http://php.net/manual/en/iterator.rewind.php
*
* @return void
*/
@@ -100,7 +96,7 @@ class RowIterator implements IteratorInterface
/**
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @see http://php.net/manual/en/iterator.valid.php
*
* @return bool
*/
@@ -111,10 +107,10 @@ class RowIterator implements IteratorInterface
/**
* Move forward to next element. Reads data for the next unprocessed row.
* @link http://php.net/manual/en/iterator.next.php
* @see http://php.net/manual/en/iterator.next.php
*
* @return void
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/
public function next()
{
@@ -126,8 +122,8 @@ class RowIterator implements IteratorInterface
}
/**
* @return void
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/
protected function readDataForNextRow()
{
@@ -167,8 +163,8 @@ class RowIterator implements IteratorInterface
* As fgetcsv() does not manage correctly encoding for non UTF-8 data,
* we remove manually whitespace with ltrim or rtrim (depending on the order of the bytes)
*
* @return array|false The row for the current file pointer, encoded in UTF-8 or FALSE if nothing to read
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return array|false The row for the current file pointer, encoded in UTF-8 or FALSE if nothing to read
*/
protected function getNextUTF8EncodedRow()
{
@@ -178,7 +174,7 @@ class RowIterator implements IteratorInterface
}
foreach ($encodedRowData as $cellIndex => $cellValue) {
switch($this->encoding) {
switch ($this->encoding) {
case EncodingHelper::ENCODING_UTF16_LE:
case EncodingHelper::ENCODING_UTF32_LE:
// remove whitespace from the beginning of a string as fgetcsv() add extra whitespace when it try to explode non UTF-8 data
@@ -209,7 +205,7 @@ class RowIterator implements IteratorInterface
/**
* Return the current element from the buffer
* @link http://php.net/manual/en/iterator.current.php
* @see http://php.net/manual/en/iterator.current.php
*
* @return array|null
*/
@@ -220,7 +216,7 @@ class RowIterator implements IteratorInterface
/**
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @see http://php.net/manual/en/iterator.key.php
*
* @return int
*/
-3
View File
@@ -2,13 +2,10 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\SheetInterface;
/**
* Class Sheet
*
* @package Box\Spout\Reader\CSV
*/
class Sheet implements SheetInterface
{
+5 -8
View File
@@ -2,14 +2,11 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\IteratorInterface;
/**
* Class SheetIterator
* Iterate over CSV unique "sheet".
*
* @package Box\Spout\Reader\CSV
*/
class SheetIterator implements IteratorInterface
{
@@ -29,7 +26,7 @@ class SheetIterator implements IteratorInterface
/**
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @see http://php.net/manual/en/iterator.rewind.php
*
* @return void
*/
@@ -40,7 +37,7 @@ class SheetIterator implements IteratorInterface
/**
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @see http://php.net/manual/en/iterator.valid.php
*
* @return bool
*/
@@ -51,7 +48,7 @@ class SheetIterator implements IteratorInterface
/**
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @see http://php.net/manual/en/iterator.next.php
*
* @return void
*/
@@ -62,7 +59,7 @@ class SheetIterator implements IteratorInterface
/**
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @see http://php.net/manual/en/iterator.current.php
*
* @return \Box\Spout\Reader\CSV\Sheet
*/
@@ -73,7 +70,7 @@ class SheetIterator implements IteratorInterface
/**
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @see http://php.net/manual/en/iterator.key.php
*
* @return int
*/