Fix code style

This commit is contained in:
Adrien Loison 2017-09-05 23:39:54 +02:00
parent 740fcfb8c1
commit b968513cb9
171 changed files with 517 additions and 792 deletions

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Autoloader;
/** /**
* Class Psr4Autoloader * Class Psr4Autoloader
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md#class-example * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md#class-example
*
* @package Box\Spout\Autoloader
*/ */
class Psr4Autoloader class Psr4Autoloader
{ {
@ -16,7 +14,7 @@ class Psr4Autoloader
* *
* @var array * @var array
*/ */
protected $prefixes = array(); protected $prefixes = [];
/** /**
* Register loader with SPL autoloader stack. * Register loader with SPL autoloader stack.
@ -25,7 +23,7 @@ class Psr4Autoloader
*/ */
public function register() public function register()
{ {
spl_autoload_register(array($this, 'loadClass')); spl_autoload_register([$this, 'loadClass']);
} }
/** /**
@ -49,7 +47,7 @@ class Psr4Autoloader
// initialize the namespace prefix array // initialize the namespace prefix array
if (isset($this->prefixes[$prefix]) === false) { if (isset($this->prefixes[$prefix]) === false) {
$this->prefixes[$prefix] = array(); $this->prefixes[$prefix] = [];
} }
// retain the base directory for the namespace prefix // retain the base directory for the namespace prefix
@ -75,7 +73,6 @@ class Psr4Autoloader
// work backwards through the namespace names of the fully-qualified // work backwards through the namespace names of the fully-qualified
// class name to find a mapped file name // class name to find a mapped file name
while (false !== $pos = strrpos($prefix, '\\')) { while (false !== $pos = strrpos($prefix, '\\')) {
// retain the trailing namespace separator in the prefix // retain the trailing namespace separator in the prefix
$prefix = substr($class, 0, $pos + 1); $prefix = substr($class, 0, $pos + 1);
@ -114,7 +111,6 @@ class Psr4Autoloader
// look through base directories for this namespace prefix // look through base directories for this namespace prefix
foreach ($this->prefixes[$prefix] as $baseDir) { foreach ($this->prefixes[$prefix] as $baseDir) {
// replace the namespace prefix with the base directory, // replace the namespace prefix with the base directory,
// replace namespace separators with directory separators // replace namespace separators with directory separators
// in the relative class name, append with .php // in the relative class name, append with .php
@ -143,8 +139,10 @@ class Psr4Autoloader
{ {
if (file_exists($file)) { if (file_exists($file)) {
require $file; require $file;
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -5,7 +5,7 @@ namespace Box\Spout\Autoloader;
require_once 'Psr4Autoloader.php'; require_once 'Psr4Autoloader.php';
/** /**
* @var string $srcBaseDirectory * @var string
* Full path to "src/Spout" which is what we want "Box\Spout" to map to. * Full path to "src/Spout" which is what we want "Box\Spout" to map to.
*/ */
$srcBaseDirectory = dirname(dirname(__FILE__)); $srcBaseDirectory = dirname(dirname(__FILE__));

View File

@ -10,8 +10,6 @@ use Box\Spout\Common\Helper\StringHelper;
/** /**
* Class HelperFactory * Class HelperFactory
* Factory to create helpers * Factory to create helpers
*
* @package Box\Spout\Common\Creator
*/ */
class HelperFactory class HelperFactory
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Common\Exception;
* Class EncodingConversionException * Class EncodingConversionException
* *
* @api * @api
* @package Box\Spout\Common\Exception
*/ */
class EncodingConversionException extends SpoutException class EncodingConversionException extends SpoutException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Common\Exception;
* Class IOException * Class IOException
* *
* @api * @api
* @package Box\Spout\Common\Exception
*/ */
class IOException extends SpoutException class IOException extends SpoutException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Common\Exception;
* Class InvalidArgumentException * Class InvalidArgumentException
* *
* @api * @api
* @package Box\Spout\Common\Exception
*/ */
class InvalidArgumentException extends SpoutException class InvalidArgumentException extends SpoutException
{ {

View File

@ -5,7 +5,6 @@ namespace Box\Spout\Common\Exception;
/** /**
* Class SpoutException * Class SpoutException
* *
* @package Box\Spout\Common\Exception
* @abstract * @abstract
*/ */
abstract class SpoutException extends \Exception abstract class SpoutException extends \Exception

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Common\Exception;
* Class UnsupportedTypeException * Class UnsupportedTypeException
* *
* @api * @api
* @package Box\Spout\Common\Exception
*/ */
class UnsupportedTypeException extends SpoutException class UnsupportedTypeException extends SpoutException
{ {

View File

@ -7,8 +7,6 @@ use Box\Spout\Common\Exception\EncodingConversionException;
/** /**
* Class EncodingHelper * Class EncodingHelper
* This class provides helper functions to work with encodings. * This class provides helper functions to work with encodings.
*
* @package Box\Spout\Common\Helper
*/ */
class EncodingHelper class EncodingHelper
{ {
@ -97,8 +95,8 @@ class EncodingHelper
* *
* @param string $string Non UTF-8 string to be converted * @param string $string Non UTF-8 string to be converted
* @param string $sourceEncoding The encoding used to encode the source string * @param string $sourceEncoding The encoding used to encode the source string
* @return string The converted, UTF-8 string
* @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed * @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed
* @return string The converted, UTF-8 string
*/ */
public function attemptConversionToUTF8($string, $sourceEncoding) public function attemptConversionToUTF8($string, $sourceEncoding)
{ {
@ -110,8 +108,8 @@ class EncodingHelper
* *
* @param string $string UTF-8 string to be converted * @param string $string UTF-8 string to be converted
* @param string $targetEncoding The encoding the string should be re-encoded into * @param string $targetEncoding The encoding the string should be re-encoded into
* @return string The converted string, encoded with the given encoding
* @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed * @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed
* @return string The converted string, encoded with the given encoding
*/ */
public function attemptConversionFromUTF8($string, $targetEncoding) public function attemptConversionFromUTF8($string, $targetEncoding)
{ {
@ -125,8 +123,8 @@ class EncodingHelper
* @param string $string string to be converted * @param string $string string to be converted
* @param string $sourceEncoding The encoding used to encode the source string * @param string $sourceEncoding The encoding used to encode the source string
* @param string $targetEncoding The encoding the string should be re-encoded into * @param string $targetEncoding The encoding the string should be re-encoded into
* @return string The converted string, encoded with the given encoding
* @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed * @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed
* @return string The converted string, encoded with the given encoding
*/ */
protected function attemptConversion($string, $sourceEncoding, $targetEncoding) protected function attemptConversion($string, $sourceEncoding, $targetEncoding)
{ {
@ -139,7 +137,7 @@ class EncodingHelper
if ($this->canUseIconv()) { if ($this->canUseIconv()) {
$convertedString = $this->globalFunctionsHelper->iconv($string, $sourceEncoding, $targetEncoding); $convertedString = $this->globalFunctionsHelper->iconv($string, $sourceEncoding, $targetEncoding);
} else if ($this->canUseMbString()) { } elseif ($this->canUseMbString()) {
$convertedString = $this->globalFunctionsHelper->mb_convert_encoding($string, $sourceEncoding, $targetEncoding); $convertedString = $this->globalFunctionsHelper->mb_convert_encoding($string, $sourceEncoding, $targetEncoding);
} else { } else {
throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding is not supported. Please install \"iconv\" or \"PHP Intl\"."); throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding is not supported. Please install \"iconv\" or \"PHP Intl\".");

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Common\Helper\Escaper;
/** /**
* Class CSV * Class CSV
* Provides functions to escape and unescape data for CSV files * Provides functions to escape and unescape data for CSV files
*
* @package Box\Spout\Common\Helper\Escaper
*/ */
class CSV implements EscaperInterface class CSV implements EscaperInterface
{ {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Common\Helper\Escaper;
/** /**
* Interface EscaperInterface * Interface EscaperInterface
*
* @package Box\Spout\Common\Helper\Escaper
*/ */
interface EscaperInterface interface EscaperInterface
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Common\Helper\Escaper;
/** /**
* Class ODS * Class ODS
* Provides functions to escape and unescape data for ODS files * Provides functions to escape and unescape data for ODS files
*
* @package Box\Spout\Common\Helper\Escaper
*/ */
class ODS implements EscaperInterface class ODS implements EscaperInterface
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Common\Helper\Escaper;
/** /**
* Class XLSX * Class XLSX
* Provides functions to escape and unescape data for XLSX files * Provides functions to escape and unescape data for XLSX files
*
* @package Box\Spout\Common\Helper\Escaper
*/ */
class XLSX implements EscaperInterface class XLSX implements EscaperInterface
{ {
@ -95,7 +93,7 @@ class XLSX implements EscaperInterface
* "\t", "\r" and "\n" don't need to be escaped. * "\t", "\r" and "\n" don't need to be escaped.
* *
* NOTE: the logic has been adapted from the XlsxWriter library (BSD License) * NOTE: the logic has been adapted from the XlsxWriter library (BSD License)
* @link https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89 * @see https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89
* *
* @return string[] * @return string[]
*/ */
@ -108,7 +106,7 @@ class XLSX implements EscaperInterface
$character = chr($charValue); $character = chr($charValue);
if (preg_match("/{$this->escapableControlCharactersPattern}/", $character)) { if (preg_match("/{$this->escapableControlCharactersPattern}/", $character)) {
$charHexValue = dechex($charValue); $charHexValue = dechex($charValue);
$escapedChar = '_x' . sprintf('%04s' , strtoupper($charHexValue)) . '_'; $escapedChar = '_x' . sprintf('%04s', strtoupper($charHexValue)) . '_';
$controlCharactersEscapingMap[$escapedChar] = $character; $controlCharactersEscapingMap[$escapedChar] = $character;
} }
} }
@ -124,7 +122,7 @@ class XLSX implements EscaperInterface
* So "\0" -> _x0000_ and "_x0000_" -> _x005F_x0000_. * So "\0" -> _x0000_ and "_x0000_" -> _x005F_x0000_.
* *
* NOTE: the logic has been adapted from the XlsxWriter library (BSD License) * NOTE: the logic has been adapted from the XlsxWriter library (BSD License)
* @link https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89 * @see https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89
* *
* @param string $string String to escape * @param string $string String to escape
* @return string * @return string
@ -138,7 +136,7 @@ class XLSX implements EscaperInterface
return $escapedString; return $escapedString;
} }
return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function($matches) { return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function ($matches) {
return $this->controlCharactersEscapingReverseMap[$matches[0]]; return $this->controlCharactersEscapingReverseMap[$matches[0]];
}, $escapedString); }, $escapedString);
} }
@ -162,7 +160,7 @@ class XLSX implements EscaperInterface
* So "_x0000_" -> "\0" and "_x005F_x0000_" -> "_x0000_" * So "_x0000_" -> "\0" and "_x005F_x0000_" -> "_x0000_"
* *
* NOTE: the logic has been adapted from the XlsxWriter library (BSD License) * NOTE: the logic has been adapted from the XlsxWriter library (BSD License)
* @link https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89 * @see https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89
* *
* @param string $string String to unescape * @param string $string String to unescape
* @return string * @return string

View File

@ -8,8 +8,6 @@ use Box\Spout\Common\Exception\IOException;
* Class FileSystemHelper * Class FileSystemHelper
* This class provides helper functions to help with the file system operations * This class provides helper functions to help with the file system operations
* like files/folders creation & deletion * like files/folders creation & deletion
*
* @package Box\Spout\Common\Helper
*/ */
class FileSystemHelper implements FileSystemHelperInterface class FileSystemHelper implements FileSystemHelperInterface
{ {
@ -29,8 +27,8 @@ class FileSystemHelper implements FileSystemHelperInterface
* *
* @param string $parentFolderPath The parent folder path under which the folder is going to be created * @param string $parentFolderPath The parent folder path under which the folder is going to be created
* @param string $folderName The name of the folder to create * @param string $folderName The name of the folder to create
* @return string Path of the created folder
* @throws \Box\Spout\Common\Exception\IOException If unable to create the folder or if the folder path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If unable to create the folder or if the folder path is not inside of the base folder
* @return string Path of the created folder
*/ */
public function createFolder($parentFolderPath, $folderName) public function createFolder($parentFolderPath, $folderName)
{ {
@ -53,8 +51,8 @@ class FileSystemHelper implements FileSystemHelperInterface
* @param string $parentFolderPath The parent folder path where the file is going to be created * @param string $parentFolderPath The parent folder path where the file is going to be created
* @param string $fileName The name of the file to create * @param string $fileName The name of the file to create
* @param string $fileContents The contents of the file to create * @param string $fileContents The contents of the file to create
* @return string Path of the created file
* @throws \Box\Spout\Common\Exception\IOException If unable to create the file or if the file path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If unable to create the file or if the file path is not inside of the base folder
* @return string Path of the created file
*/ */
public function createFileWithContents($parentFolderPath, $fileName, $fileContents) public function createFileWithContents($parentFolderPath, $fileName, $fileContents)
{ {
@ -74,8 +72,8 @@ class FileSystemHelper implements FileSystemHelperInterface
* Delete the file at the given path * Delete the file at the given path
* *
* @param string $filePath Path of the file to delete * @param string $filePath Path of the file to delete
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the file path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If the file path is not inside of the base folder
* @return void
*/ */
public function deleteFile($filePath) public function deleteFile($filePath)
{ {
@ -90,8 +88,8 @@ class FileSystemHelper implements FileSystemHelperInterface
* Delete the folder at the given path as well as all its contents * Delete the folder at the given path as well as all its contents
* *
* @param string $folderPath Path of the folder to delete * @param string $folderPath Path of the folder to delete
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the folder path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If the folder path is not inside of the base folder
* @return void
*/ */
public function deleteFolderRecursively($folderPath) public function deleteFolderRecursively($folderPath)
{ {
@ -119,8 +117,8 @@ class FileSystemHelper implements FileSystemHelperInterface
* should occur is not inside the base folder. * should occur is not inside the base folder.
* *
* @param string $operationFolderPath The path of the folder where the I/O operation should occur * @param string $operationFolderPath The path of the folder where the I/O operation should occur
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the folder where the I/O operation should occur is not inside the base folder * @throws \Box\Spout\Common\Exception\IOException If the folder where the I/O operation should occur is not inside the base folder
* @return void
*/ */
protected function throwIfOperationNotInBaseFolder($operationFolderPath) protected function throwIfOperationNotInBaseFolder($operationFolderPath)
{ {

View File

@ -6,8 +6,6 @@ namespace Box\Spout\Common\Helper;
* Class FileSystemHelperInterface * Class FileSystemHelperInterface
* This interface describes helper functions to help with the file system operations * This interface describes helper functions to help with the file system operations
* like files/folders creation & deletion * like files/folders creation & deletion
*
* @package Box\Spout\Common\Helper
*/ */
interface FileSystemHelperInterface interface FileSystemHelperInterface
{ {
@ -16,8 +14,8 @@ interface FileSystemHelperInterface
* *
* @param string $parentFolderPath The parent folder path under which the folder is going to be created * @param string $parentFolderPath The parent folder path under which the folder is going to be created
* @param string $folderName The name of the folder to create * @param string $folderName The name of the folder to create
* @return string Path of the created folder
* @throws \Box\Spout\Common\Exception\IOException If unable to create the folder or if the folder path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If unable to create the folder or if the folder path is not inside of the base folder
* @return string Path of the created folder
*/ */
public function createFolder($parentFolderPath, $folderName); public function createFolder($parentFolderPath, $folderName);
@ -28,8 +26,8 @@ interface FileSystemHelperInterface
* @param string $parentFolderPath The parent folder path where the file is going to be created * @param string $parentFolderPath The parent folder path where the file is going to be created
* @param string $fileName The name of the file to create * @param string $fileName The name of the file to create
* @param string $fileContents The contents of the file to create * @param string $fileContents The contents of the file to create
* @return string Path of the created file
* @throws \Box\Spout\Common\Exception\IOException If unable to create the file or if the file path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If unable to create the file or if the file path is not inside of the base folder
* @return string Path of the created file
*/ */
public function createFileWithContents($parentFolderPath, $fileName, $fileContents); public function createFileWithContents($parentFolderPath, $fileName, $fileContents);
@ -37,8 +35,8 @@ interface FileSystemHelperInterface
* Delete the file at the given path * Delete the file at the given path
* *
* @param string $filePath Path of the file to delete * @param string $filePath Path of the file to delete
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the file path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If the file path is not inside of the base folder
* @return void
*/ */
public function deleteFile($filePath); public function deleteFile($filePath);
@ -46,8 +44,8 @@ interface FileSystemHelperInterface
* Delete the folder at the given path as well as all its contents * Delete the folder at the given path as well as all its contents
* *
* @param string $folderPath Path of the folder to delete * @param string $folderPath Path of the folder to delete
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the folder path is not inside of the base folder * @throws \Box\Spout\Common\Exception\IOException If the folder path is not inside of the base folder
* @return void
*/ */
public function deleteFolderRecursively($folderPath); public function deleteFolderRecursively($folderPath);
} }

View File

@ -7,8 +7,6 @@ namespace Box\Spout\Common\Helper;
* This class wraps global functions to facilitate testing * This class wraps global functions to facilitate testing
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @package Box\Spout\Common\Helper
*/ */
class GlobalFunctionsHelper class GlobalFunctionsHelper
{ {
@ -165,6 +163,7 @@ class GlobalFunctionsHelper
public function file_get_contents($filePath) public function file_get_contents($filePath)
{ {
$realFilePath = $this->convertToUseRealPath($filePath); $realFilePath = $this->convertToUseRealPath($filePath);
return file_get_contents($realFilePath); return file_get_contents($realFilePath);
} }

View File

@ -7,8 +7,6 @@ namespace Box\Spout\Common\Helper;
* This class provides helper functions to work with strings and multibyte strings. * This class provides helper functions to work with strings and multibyte strings.
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @package Box\Spout\Common\Helper
*/ */
class StringHelper class StringHelper
{ {
@ -50,6 +48,7 @@ class StringHelper
public function getCharFirstOccurrencePosition($char, $string) public function getCharFirstOccurrencePosition($char, $string)
{ {
$position = $this->hasMbstringSupport ? mb_strpos($string, $char) : strpos($string, $char); $position = $this->hasMbstringSupport ? mb_strpos($string, $char) : strpos($string, $char);
return ($position !== false) ? $position : -1; return ($position !== false) ? $position : -1;
} }
@ -66,6 +65,7 @@ class StringHelper
public function getCharLastOccurrencePosition($char, $string) public function getCharLastOccurrencePosition($char, $string)
{ {
$position = $this->hasMbstringSupport ? mb_strrpos($string, $char) : strrpos($string, $char); $position = $this->hasMbstringSupport ? mb_strrpos($string, $char) : strrpos($string, $char);
return ($position !== false) ? $position : -1; return ($position !== false) ? $position : -1;
} }
} }

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Common\Manager;
/** /**
* Class OptionsManager * Class OptionsManager
*
* @package Box\Spout\Common\Manager
*/ */
abstract class OptionsManagerAbstract implements OptionsManagerInterface abstract class OptionsManagerAbstract implements OptionsManagerInterface
{ {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Common\Manager;
/** /**
* Interface OptionsManagerInterface * Interface OptionsManagerInterface
*
* @package Box\Spout\Common\Manager
*/ */
interface OptionsManagerInterface interface OptionsManagerInterface
{ {

View File

@ -13,8 +13,6 @@ use Box\Spout\Reader\CSV\SheetIterator;
/** /**
* Class EntityFactory * Class EntityFactory
* Factory to create entities * Factory to create entities
*
* @package Box\Spout\Reader\CSV\Creator
*/ */
class EntityFactory implements EntityFactoryInterface class EntityFactory implements EntityFactoryInterface
{ {
@ -61,6 +59,7 @@ class EntityFactory implements EntityFactoryInterface
private function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper) private function createRowIterator($filePointer, $optionsManager, $globalFunctionsHelper)
{ {
$encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper); $encodingHelper = $this->helperFactory->createEncodingHelper($globalFunctionsHelper);
return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper); return new RowIterator($filePointer, $optionsManager, $encodingHelper, $globalFunctionsHelper);
} }
} }

View File

@ -9,13 +9,11 @@ use Box\Spout\Reader\Common\Entity\Options;
/** /**
* Class OptionsManager * Class OptionsManager
* CSV Reader options manager * CSV Reader options manager
*
* @package Box\Spout\Reader\CSV\Manager
*/ */
class OptionsManager extends OptionsManagerAbstract class OptionsManager extends OptionsManagerAbstract
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSupportedOptions() protected function getSupportedOptions()
{ {
@ -29,7 +27,7 @@ class OptionsManager extends OptionsManagerAbstract
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function setDefaultOptions() protected function setDefaultOptions()
{ {

View File

@ -2,16 +2,14 @@
namespace Box\Spout\Reader\CSV; namespace Box\Spout\Reader\CSV;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Reader\Common\Entity\Options; use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\Creator\EntityFactory; use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\ReaderAbstract; use Box\Spout\Reader\ReaderAbstract;
use Box\Spout\Common\Exception\IOException;
/** /**
* Class Reader * Class Reader
* This class provides support to read data from a CSV file. * This class provides support to read data from a CSV file.
*
* @package Box\Spout\Reader\CSV
*/ */
class Reader extends ReaderAbstract class Reader extends ReaderAbstract
{ {
@ -34,6 +32,7 @@ class Reader extends ReaderAbstract
public function setFieldDelimiter($fieldDelimiter) public function setFieldDelimiter($fieldDelimiter)
{ {
$this->optionsManager->setOption(Options::FIELD_DELIMITER, $fieldDelimiter); $this->optionsManager->setOption(Options::FIELD_DELIMITER, $fieldDelimiter);
return $this; return $this;
} }
@ -47,6 +46,7 @@ class Reader extends ReaderAbstract
public function setFieldEnclosure($fieldEnclosure) public function setFieldEnclosure($fieldEnclosure)
{ {
$this->optionsManager->setOption(Options::FIELD_ENCLOSURE, $fieldEnclosure); $this->optionsManager->setOption(Options::FIELD_ENCLOSURE, $fieldEnclosure);
return $this; return $this;
} }
@ -60,6 +60,7 @@ class Reader extends ReaderAbstract
public function setEncoding($encoding) public function setEncoding($encoding)
{ {
$this->optionsManager->setOption(Options::ENCODING, $encoding); $this->optionsManager->setOption(Options::ENCODING, $encoding);
return $this; 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. * 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 * @param string $filePath Path of the CSV file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException * @throws \Box\Spout\Common\Exception\IOException
* @return void
*/ */
protected function openReader($filePath) protected function openReader($filePath)
{ {
@ -111,7 +112,6 @@ class Reader extends ReaderAbstract
return $this->sheetIterator; return $this->sheetIterator;
} }
/** /**
* Closes the reader. To be used after reading the file. * Closes the reader. To be used after reading the file.
* *

View File

@ -2,17 +2,13 @@
namespace Box\Spout\Reader\CSV; 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\Common\Helper\EncodingHelper;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\IteratorInterface;
/** /**
* Class RowIterator * Class RowIterator
* Iterate over CSV rows. * Iterate over CSV rows.
*
* @package Box\Spout\Reader\CSV
*/ */
class RowIterator implements IteratorInterface class RowIterator implements IteratorInterface
{ {
@ -28,7 +24,7 @@ class RowIterator implements IteratorInterface
protected $numReadRows = 0; protected $numReadRows = 0;
/** @var array|null Buffer used to store the row data, while checking if there are more rows to read */ /** @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 */ /** @var bool Indicates whether all rows have been read */
protected $hasReachedEndOfFile = false; protected $hasReachedEndOfFile = false;
@ -70,7 +66,7 @@ class RowIterator implements IteratorInterface
/** /**
* Rewind the Iterator to the first element * 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 * @return void
*/ */
@ -100,7 +96,7 @@ class RowIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -111,10 +107,10 @@ class RowIterator implements IteratorInterface
/** /**
* Move forward to next element. Reads data for the next unprocessed row. * 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 * @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/ */
public function next() 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 * @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/ */
protected function readDataForNextRow() protected function readDataForNextRow()
{ {
@ -167,8 +163,8 @@ class RowIterator implements IteratorInterface
* As fgetcsv() does not manage correctly encoding for non UTF-8 data, * 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) * 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 * @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() protected function getNextUTF8EncodedRow()
{ {
@ -178,7 +174,7 @@ class RowIterator implements IteratorInterface
} }
foreach ($encodedRowData as $cellIndex => $cellValue) { foreach ($encodedRowData as $cellIndex => $cellValue) {
switch($this->encoding) { switch ($this->encoding) {
case EncodingHelper::ENCODING_UTF16_LE: case EncodingHelper::ENCODING_UTF16_LE:
case EncodingHelper::ENCODING_UTF32_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 // 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 * 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 * @return array|null
*/ */
@ -220,7 +216,7 @@ class RowIterator implements IteratorInterface
/** /**
* Return the key of the current element * 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 * @return int
*/ */

View File

@ -2,13 +2,10 @@
namespace Box\Spout\Reader\CSV; namespace Box\Spout\Reader\CSV;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\SheetInterface; use Box\Spout\Reader\SheetInterface;
/** /**
* Class Sheet * Class Sheet
*
* @package Box\Spout\Reader\CSV
*/ */
class Sheet implements SheetInterface class Sheet implements SheetInterface
{ {

View File

@ -2,14 +2,11 @@
namespace Box\Spout\Reader\CSV; namespace Box\Spout\Reader\CSV;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\IteratorInterface; use Box\Spout\Reader\IteratorInterface;
/** /**
* Class SheetIterator * Class SheetIterator
* Iterate over CSV unique "sheet". * Iterate over CSV unique "sheet".
*
* @package Box\Spout\Reader\CSV
*/ */
class SheetIterator implements IteratorInterface class SheetIterator implements IteratorInterface
{ {
@ -29,7 +26,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Rewind the Iterator to the first element * 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 * @return void
*/ */
@ -40,7 +37,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -51,7 +48,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Move forward to next element * 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 * @return void
*/ */
@ -62,7 +59,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the current element * 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 * @return \Box\Spout\Reader\CSV\Sheet
*/ */
@ -73,7 +70,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the key of the current element * 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 * @return int
*/ */

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader\Common\Creator;
/** /**
* Interface EntityFactoryInterface * Interface EntityFactoryInterface
*
* @package Box\Spout\Reader\Common\Creator
*/ */
interface EntityFactoryInterface interface EntityFactoryInterface
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Reader\Common\Entity;
/** /**
* Class Options * Class Options
* Readers' options holder * Readers' options holder
*
* @package Box\Spout\Reader\Common\Entity
*/ */
abstract class Options abstract class Options
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Reader\Common;
/** /**
* Class ReaderOptions * Class ReaderOptions
* Readers' common options * Readers' common options
*
* @package Box\Spout\Reader\Common
*/ */
class ReaderOptions class ReaderOptions
{ {
@ -33,6 +31,7 @@ class ReaderOptions
public function setShouldFormatDates($shouldFormatDates) public function setShouldFormatDates($shouldFormatDates)
{ {
$this->shouldFormatDates = $shouldFormatDates; $this->shouldFormatDates = $shouldFormatDates;
return $this; return $this;
} }
@ -53,6 +52,7 @@ class ReaderOptions
public function setShouldPreserveEmptyRows($shouldPreserveEmptyRows) public function setShouldPreserveEmptyRows($shouldPreserveEmptyRows)
{ {
$this->shouldPreserveEmptyRows = $shouldPreserveEmptyRows; $this->shouldPreserveEmptyRows = $shouldPreserveEmptyRows;
return $this; return $this;
} }
} }

View File

@ -7,8 +7,6 @@ use Box\Spout\Reader\Wrapper\XMLReader;
/** /**
* Class XMLProcessor * Class XMLProcessor
* Helps process XML files * Helps process XML files
*
* @package Box\Spout\Reader\Common
*/ */
class XMLProcessor class XMLProcessor
{ {
@ -24,14 +22,12 @@ class XMLProcessor
const PROCESSING_CONTINUE = 1; const PROCESSING_CONTINUE = 1;
const PROCESSING_STOP = 2; const PROCESSING_STOP = 2;
/** @var \Box\Spout\Reader\Wrapper\XMLReader The XMLReader object that will help read sheet's XML data */ /** @var \Box\Spout\Reader\Wrapper\XMLReader The XMLReader object that will help read sheet's XML data */
protected $xmlReader; protected $xmlReader;
/** @var array Registered callbacks */ /** @var array Registered callbacks */
private $callbacks = []; private $callbacks = [];
/** /**
* @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object
*/ */
@ -90,8 +86,8 @@ class XMLProcessor
* Resumes the reading of the XML file where it was left off. * Resumes the reading of the XML file where it was left off.
* Stops whenever a callback indicates that reading should stop or at the end of the file. * Stops whenever a callback indicates that reading should stop or at the end of the file.
* *
* @return void
* @throws \Box\Spout\Reader\Exception\XMLProcessingException * @throws \Box\Spout\Reader\Exception\XMLProcessingException
* @return void
*/ */
public function readUntilStopped() public function readUntilStopped()
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Reader\Exception;
* Class IteratorNotRewindableException * Class IteratorNotRewindableException
* *
* @api * @api
* @package Box\Spout\Reader\Exception
*/ */
class IteratorNotRewindableException extends ReaderException class IteratorNotRewindableException extends ReaderException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Reader\Exception;
* Class NoSheetsFoundException * Class NoSheetsFoundException
* *
* @api * @api
* @package Box\Spout\Reader\Exception
*/ */
class NoSheetsFoundException extends ReaderException class NoSheetsFoundException extends ReaderException
{ {

View File

@ -7,7 +7,6 @@ use Box\Spout\Common\Exception\SpoutException;
/** /**
* Class ReaderException * Class ReaderException
* *
* @package Box\Spout\Reader\Exception
* @abstract * @abstract
*/ */
abstract class ReaderException extends SpoutException abstract class ReaderException extends SpoutException

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Reader\Exception;
* Class ReaderNotOpenedException * Class ReaderNotOpenedException
* *
* @api * @api
* @package Box\Spout\Reader\Exception
*/ */
class ReaderNotOpenedException extends ReaderException class ReaderNotOpenedException extends ReaderException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Reader\Exception;
* Class SharedStringNotFoundException * Class SharedStringNotFoundException
* *
* @api * @api
* @package Box\Spout\Reader\Exception
*/ */
class SharedStringNotFoundException extends ReaderException class SharedStringNotFoundException extends ReaderException
{ {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader\Exception;
/** /**
* Class XMLProcessingException * Class XMLProcessingException
*
* @package Box\Spout\Reader\Exception
*/ */
class XMLProcessingException extends ReaderException class XMLProcessingException extends ReaderException
{ {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader;
/** /**
* Interface IteratorInterface * Interface IteratorInterface
*
* @package Box\Spout\Reader
*/ */
interface IteratorInterface extends \Iterator interface IteratorInterface extends \Iterator
{ {

View File

@ -2,8 +2,6 @@
namespace Box\Spout\Reader\ODS\Creator; namespace Box\Spout\Reader\ODS\Creator;
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface; use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
use Box\Spout\Reader\Common\Entity\Options; use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\Common\XMLProcessor; use Box\Spout\Reader\Common\XMLProcessor;
@ -15,8 +13,6 @@ use Box\Spout\Reader\Wrapper\XMLReader;
/** /**
* Class EntityFactory * Class EntityFactory
* Factory to create entities * Factory to create entities
*
* @package Box\Spout\Reader\ODS\Creator
*/ */
class EntityFactory implements EntityFactoryInterface class EntityFactory implements EntityFactoryInterface
{ {

View File

@ -5,12 +5,9 @@ namespace Box\Spout\Reader\ODS\Creator;
use Box\Spout\Reader\ODS\Helper\CellValueFormatter; use Box\Spout\Reader\ODS\Helper\CellValueFormatter;
use Box\Spout\Reader\ODS\Helper\SettingsHelper; use Box\Spout\Reader\ODS\Helper\SettingsHelper;
/** /**
* Class EntityFactory * Class EntityFactory
* Factory to create helpers * Factory to create helpers
*
* @package Box\Spout\Reader\ODS\Creator
*/ */
class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
{ {
@ -21,6 +18,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
public function createCellValueFormatter($shouldFormatDates) public function createCellValueFormatter($shouldFormatDates)
{ {
$escaper = $this->createStringsEscaper(); $escaper = $this->createStringsEscaper();
return new CellValueFormatter($shouldFormatDates, $escaper); return new CellValueFormatter($shouldFormatDates, $escaper);
} }
@ -38,7 +36,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
*/ */
public function createStringsEscaper() public function createStringsEscaper()
{ {
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ /* @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
return new \Box\Spout\Common\Helper\Escaper\ODS(); return new \Box\Spout\Common\Helper\Escaper\ODS();
} }
} }

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Reader\ODS\Helper;
/** /**
* Class CellValueFormatter * Class CellValueFormatter
* This class provides helper functions to format cell values * This class provides helper functions to format cell values
*
* @package Box\Spout\Reader\ODS\Helper
*/ */
class CellValueFormatter class CellValueFormatter
{ {
@ -100,11 +98,11 @@ class CellValueFormatter
foreach ($pNode->childNodes as $childNode) { foreach ($pNode->childNodes as $childNode) {
if ($childNode instanceof \DOMText) { if ($childNode instanceof \DOMText) {
$currentPValue .= $childNode->nodeValue; $currentPValue .= $childNode->nodeValue;
} else if ($childNode->nodeName === self::XML_NODE_S) { } elseif ($childNode->nodeName === self::XML_NODE_S) {
$spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C); $spaceAttribute = $childNode->getAttribute(self::XML_ATTRIBUTE_C);
$numSpaces = (!empty($spaceAttribute)) ? intval($spaceAttribute) : 1; $numSpaces = (!empty($spaceAttribute)) ? (int) $spaceAttribute : 1;
$currentPValue .= str_repeat(' ', $numSpaces); $currentPValue .= str_repeat(' ', $numSpaces);
} else if ($childNode->nodeName === self::XML_NODE_A || $childNode->nodeName === self::XML_NODE_SPAN) { } elseif ($childNode->nodeName === self::XML_NODE_A || $childNode->nodeName === self::XML_NODE_SPAN) {
$currentPValue .= $childNode->nodeValue; $currentPValue .= $childNode->nodeValue;
} }
} }
@ -114,6 +112,7 @@ class CellValueFormatter
$escapedCellValue = implode("\n", $pNodeValues); $escapedCellValue = implode("\n", $pNodeValues);
$cellValue = $this->escaper->unescape($escapedCellValue); $cellValue = $this->escaper->unescape($escapedCellValue);
return $cellValue; return $cellValue;
} }
@ -126,9 +125,11 @@ class CellValueFormatter
protected function formatFloatCellValue($node) protected function formatFloatCellValue($node)
{ {
$nodeValue = $node->getAttribute(self::XML_ATTRIBUTE_VALUE); $nodeValue = $node->getAttribute(self::XML_ATTRIBUTE_VALUE);
$nodeIntValue = intval($nodeValue);
$nodeIntValue = (int) $nodeValue;
$nodeFloatValue = (float) $nodeValue; $nodeFloatValue = (float) $nodeValue;
$cellValue = ((float) $nodeIntValue === $nodeFloatValue) ? $nodeIntValue : $nodeFloatValue; $cellValue = ((float) $nodeIntValue === $nodeFloatValue) ? $nodeIntValue : $nodeFloatValue;
return $cellValue; return $cellValue;
} }
@ -141,6 +142,7 @@ class CellValueFormatter
protected function formatBooleanCellValue($node) protected function formatBooleanCellValue($node)
{ {
$nodeValue = $node->getAttribute(self::XML_ATTRIBUTE_BOOLEAN_VALUE); $nodeValue = $node->getAttribute(self::XML_ATTRIBUTE_BOOLEAN_VALUE);
return (bool) $nodeValue; return (bool) $nodeValue;
} }

View File

@ -4,13 +4,10 @@ namespace Box\Spout\Reader\ODS\Helper;
use Box\Spout\Reader\Exception\XMLProcessingException; use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\Reader\ODS\Creator\EntityFactory; use Box\Spout\Reader\ODS\Creator\EntityFactory;
use Box\Spout\Reader\Wrapper\XMLReader;
/** /**
* Class SettingsHelper * Class SettingsHelper
* This class provides helper functions to extract data from the "settings.xml" file. * This class provides helper functions to extract data from the "settings.xml" file.
*
* @package Box\Spout\Reader\ODS\Helper
*/ */
class SettingsHelper class SettingsHelper
{ {

View File

@ -8,13 +8,11 @@ use Box\Spout\Reader\Common\Entity\Options;
/** /**
* Class OptionsManager * Class OptionsManager
* ODS Reader options manager * ODS Reader options manager
*
* @package Box\Spout\Reader\ODS\Manager
*/ */
class OptionsManager extends OptionsManagerAbstract class OptionsManager extends OptionsManagerAbstract
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSupportedOptions() protected function getSupportedOptions()
{ {
@ -25,7 +23,7 @@ class OptionsManager extends OptionsManagerAbstract
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function setDefaultOptions() protected function setDefaultOptions()
{ {

View File

@ -9,8 +9,6 @@ use Box\Spout\Reader\ReaderAbstract;
/** /**
* Class Reader * Class Reader
* This class provides support to read data from a ODS file * This class provides support to read data from a ODS file
*
* @package Box\Spout\Reader\ODS
*/ */
class Reader extends ReaderAbstract class Reader extends ReaderAbstract
{ {
@ -34,9 +32,9 @@ class Reader extends ReaderAbstract
* Opens the file at the given file path to make it ready to be read. * Opens the file at the given file path to make it ready to be read.
* *
* @param string $filePath Path of the file to be read * @param string $filePath Path of the file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the file at the given path or its content cannot be read * @throws \Box\Spout\Common\Exception\IOException If the file at the given path or its content cannot be read
* @throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file * @throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file
* @return void
*/ */
protected function openReader($filePath) protected function openReader($filePath)
{ {

View File

@ -4,19 +4,15 @@ namespace Box\Spout\Reader\ODS;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Reader\Common\Entity\Options; use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\Common\XMLProcessor;
use Box\Spout\Reader\Exception\IteratorNotRewindableException; use Box\Spout\Reader\Exception\IteratorNotRewindableException;
use Box\Spout\Reader\Exception\XMLProcessingException; use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\Reader\IteratorInterface; use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\ODS\Creator\EntityFactory;
use Box\Spout\Reader\ODS\Creator\HelperFactory;
use Box\Spout\Reader\ODS\Helper\CellValueFormatter; use Box\Spout\Reader\ODS\Helper\CellValueFormatter;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\Reader\Common\XMLProcessor;
/** /**
* Class RowIterator * Class RowIterator
*
* @package Box\Spout\Reader\ODS
*/ */
class RowIterator implements IteratorInterface class RowIterator implements IteratorInterface
{ {
@ -49,7 +45,7 @@ class RowIterator implements IteratorInterface
protected $currentlyProcessedRowData = []; protected $currentlyProcessedRowData = [];
/** @var array|null Buffer used to store the row data, while checking if there are more rows to read */ /** @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 */ /** @var bool Indicates whether all rows have been read */
protected $hasReachedEndOfFile = false; protected $hasReachedEndOfFile = false;
@ -61,7 +57,7 @@ class RowIterator implements IteratorInterface
protected $nextRowIndexToBeProcessed = 1; protected $nextRowIndexToBeProcessed = 1;
/** @var mixed|null Value of the last processed cell (because when reading cell at column N+1, cell N is processed) */ /** @var mixed|null Value of the last processed cell (because when reading cell at column N+1, cell N is processed) */
protected $lastProcessedCellValue = null; protected $lastProcessedCellValue;
/** @var int Number of times the last processed row should be repeated */ /** @var int Number of times the last processed row should be repeated */
protected $numRowsRepeated = 1; protected $numRowsRepeated = 1;
@ -72,7 +68,6 @@ class RowIterator implements IteratorInterface
/** @var bool Whether at least one cell has been read for the row currently being processed */ /** @var bool Whether at least one cell has been read for the row currently being processed */
protected $hasAlreadyReadOneCellInCurrentRow = false; protected $hasAlreadyReadOneCellInCurrentRow = false;
/** /**
* @param XMLReader $xmlReader XML Reader, positioned on the "<table:table>" element * @param XMLReader $xmlReader XML Reader, positioned on the "<table:table>" element
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager * @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager
@ -96,10 +91,10 @@ class RowIterator implements IteratorInterface
/** /**
* Rewind the Iterator to the first element. * Rewind the Iterator to the first element.
* NOTE: It can only be done once, as it is not possible to read an XML file backwards. * NOTE: It can only be done once, as it is not possible to read an XML file backwards.
* @link http://php.net/manual/en/iterator.rewind.php * @see http://php.net/manual/en/iterator.rewind.php
* *
* @return void
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once * @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
* @return void
*/ */
public function rewind() public function rewind()
{ {
@ -121,7 +116,7 @@ class RowIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -132,11 +127,11 @@ class RowIterator implements IteratorInterface
/** /**
* Move forward to next element. Empty rows will be skipped. * Move forward to next element. Empty rows will be skipped.
* @link http://php.net/manual/en/iterator.next.php * @see http://php.net/manual/en/iterator.next.php
* *
* @return void
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML * @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/ */
public function next() public function next()
{ {
@ -167,9 +162,9 @@ class RowIterator implements IteratorInterface
} }
/** /**
* @return void
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML * @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/ */
protected function readDataForNextRow() protected function readDataForNextRow()
{ {
@ -280,7 +275,8 @@ class RowIterator implements IteratorInterface
protected function getNumRowsRepeatedForCurrentNode($xmlReader) protected function getNumRowsRepeatedForCurrentNode($xmlReader)
{ {
$numRowsRepeated = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_ROWS_REPEATED); $numRowsRepeated = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_ROWS_REPEATED);
return ($numRowsRepeated !== null) ? intval($numRowsRepeated) : 1;
return ($numRowsRepeated !== null) ? (int) $numRowsRepeated : 1;
} }
/** /**
@ -290,7 +286,8 @@ class RowIterator implements IteratorInterface
protected function getNumColumnsRepeatedForCurrentNode($xmlReader) protected function getNumColumnsRepeatedForCurrentNode($xmlReader)
{ {
$numColumnsRepeated = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_COLUMNS_REPEATED); $numColumnsRepeated = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_COLUMNS_REPEATED);
return ($numColumnsRepeated !== null) ? intval($numColumnsRepeated) : 1;
return ($numColumnsRepeated !== null) ? (int) $numColumnsRepeated : 1;
} }
/** /**
@ -324,7 +321,7 @@ class RowIterator implements IteratorInterface
/** /**
* Return the current element, from the buffer. * 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 * @return array|null
*/ */
@ -335,7 +332,7 @@ class RowIterator implements IteratorInterface
/** /**
* Return the key of the current element * 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 * @return int
*/ */
@ -344,7 +341,6 @@ class RowIterator implements IteratorInterface
return $this->lastRowIndexProcessed; return $this->lastRowIndexProcessed;
} }
/** /**
* Cleans up what was created to iterate over the object. * Cleans up what was created to iterate over the object.
* *

View File

@ -2,15 +2,11 @@
namespace Box\Spout\Reader\ODS; namespace Box\Spout\Reader\ODS;
use Box\Spout\Reader\ODS\Creator\EntityFactory;
use Box\Spout\Reader\SheetInterface; use Box\Spout\Reader\SheetInterface;
use Box\Spout\Reader\Wrapper\XMLReader;
/** /**
* Class Sheet * Class Sheet
* Represents a sheet within a ODS file * Represents a sheet within a ODS file
*
* @package Box\Spout\Reader\ODS
*/ */
class Sheet implements SheetInterface class Sheet implements SheetInterface
{ {

View File

@ -6,15 +6,12 @@ use Box\Spout\Common\Exception\IOException;
use Box\Spout\Reader\Exception\XMLProcessingException; use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\Reader\IteratorInterface; use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\ODS\Creator\EntityFactory; use Box\Spout\Reader\ODS\Creator\EntityFactory;
use Box\Spout\Reader\ODS\Creator\HelperFactory;
use Box\Spout\Reader\ODS\Helper\SettingsHelper; use Box\Spout\Reader\ODS\Helper\SettingsHelper;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
/** /**
* Class SheetIterator * Class SheetIterator
* Iterate over ODS sheet. * Iterate over ODS sheet.
*
* @package Box\Spout\Reader\ODS
*/ */
class SheetIterator implements IteratorInterface class SheetIterator implements IteratorInterface
{ {
@ -67,10 +64,10 @@ class SheetIterator implements IteratorInterface
/** /**
* Rewind the Iterator to the first element * 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
* @throws \Box\Spout\Common\Exception\IOException If unable to open the XML file containing sheets' data * @throws \Box\Spout\Common\Exception\IOException If unable to open the XML file containing sheets' data
* @return void
*/ */
public function rewind() public function rewind()
{ {
@ -92,7 +89,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -103,7 +100,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Move forward to next element * 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 * @return void
*/ */
@ -118,7 +115,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the current element * 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\ODS\Sheet * @return \Box\Spout\Reader\ODS\Sheet
*/ */
@ -151,7 +148,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the key of the current element * 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 * @return int
*/ */

View File

@ -12,7 +12,6 @@ use Box\Spout\Reader\Exception\ReaderNotOpenedException;
/** /**
* Class ReaderAbstract * Class ReaderAbstract
* *
* @package Box\Spout\Reader
* @abstract * @abstract
*/ */
abstract class ReaderAbstract implements ReaderInterface abstract class ReaderAbstract implements ReaderInterface
@ -66,8 +65,8 @@ abstract class ReaderAbstract implements ReaderInterface
public function __construct( public function __construct(
OptionsManagerInterface $optionsManager, OptionsManagerInterface $optionsManager,
GlobalFunctionsHelper $globalFunctionsHelper, GlobalFunctionsHelper $globalFunctionsHelper,
EntityFactoryInterface $entityFactory) EntityFactoryInterface $entityFactory
{ ) {
$this->optionsManager = $optionsManager; $this->optionsManager = $optionsManager;
$this->globalFunctionsHelper = $globalFunctionsHelper; $this->globalFunctionsHelper = $globalFunctionsHelper;
$this->entityFactory = $entityFactory; $this->entityFactory = $entityFactory;
@ -83,6 +82,7 @@ abstract class ReaderAbstract implements ReaderInterface
public function setShouldFormatDates($shouldFormatDates) public function setShouldFormatDates($shouldFormatDates)
{ {
$this->optionsManager->setOption(Options::SHOULD_FORMAT_DATES, $shouldFormatDates); $this->optionsManager->setOption(Options::SHOULD_FORMAT_DATES, $shouldFormatDates);
return $this; return $this;
} }
@ -96,6 +96,7 @@ abstract class ReaderAbstract implements ReaderInterface
public function setShouldPreserveEmptyRows($shouldPreserveEmptyRows) public function setShouldPreserveEmptyRows($shouldPreserveEmptyRows)
{ {
$this->optionsManager->setOption(Options::SHOULD_PRESERVE_EMPTY_ROWS, $shouldPreserveEmptyRows); $this->optionsManager->setOption(Options::SHOULD_PRESERVE_EMPTY_ROWS, $shouldPreserveEmptyRows);
return $this; return $this;
} }
@ -105,8 +106,8 @@ abstract class ReaderAbstract implements ReaderInterface
* *
* @api * @api
* @param string $filePath Path of the file to be read * @param string $filePath Path of the file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the file at the given path does not exist, is not readable or is corrupted * @throws \Box\Spout\Common\Exception\IOException If the file at the given path does not exist, is not readable or is corrupted
* @return void
*/ */
public function open($filePath) public function open($filePath)
{ {
@ -118,7 +119,8 @@ abstract class ReaderAbstract implements ReaderInterface
// we skip the checks if the provided file path points to a PHP stream // we skip the checks if the provided file path points to a PHP stream
if (!$this->globalFunctionsHelper->file_exists($filePath)) { if (!$this->globalFunctionsHelper->file_exists($filePath)) {
throw new IOException("Could not open $filePath for reading! File does not exist."); throw new IOException("Could not open $filePath for reading! File does not exist.");
} else if (!$this->globalFunctionsHelper->is_readable($filePath)) { }
if (!$this->globalFunctionsHelper->is_readable($filePath)) {
throw new IOException("Could not open $filePath for reading! File is not readable."); throw new IOException("Could not open $filePath for reading! File is not readable.");
} }
} }
@ -162,6 +164,7 @@ abstract class ReaderAbstract implements ReaderInterface
if (preg_match('/^(\w+):\/\//', $filePath, $matches)) { if (preg_match('/^(\w+):\/\//', $filePath, $matches)) {
$streamScheme = $matches[1]; $streamScheme = $matches[1];
} }
return $streamScheme; return $streamScheme;
} }
@ -188,6 +191,7 @@ abstract class ReaderAbstract implements ReaderInterface
protected function isSupportedStreamWrapper($filePath) protected function isSupportedStreamWrapper($filePath)
{ {
$streamScheme = $this->getStreamWrapperScheme($filePath); $streamScheme = $this->getStreamWrapperScheme($filePath);
return ($streamScheme !== null) ? return ($streamScheme !== null) ?
in_array($streamScheme, $this->globalFunctionsHelper->stream_get_wrappers()) : in_array($streamScheme, $this->globalFunctionsHelper->stream_get_wrappers()) :
true; true;
@ -202,6 +206,7 @@ abstract class ReaderAbstract implements ReaderInterface
protected function isPhpStream($filePath) protected function isPhpStream($filePath)
{ {
$streamScheme = $this->getStreamWrapperScheme($filePath); $streamScheme = $this->getStreamWrapperScheme($filePath);
return ($streamScheme === 'php'); return ($streamScheme === 'php');
} }
@ -209,8 +214,8 @@ abstract class ReaderAbstract implements ReaderInterface
* Returns an iterator to iterate over sheets. * Returns an iterator to iterate over sheets.
* *
* @api * @api
* @return \Iterator To iterate over sheets
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader * @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader
* @return \Iterator To iterate over sheets
*/ */
public function getSheetIterator() public function getSheetIterator()
{ {

View File

@ -11,8 +11,6 @@ use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory;
* Class ReaderFactory * Class ReaderFactory
* This factory is used to create readers, based on the type of the file to be read. * This factory is used to create readers, based on the type of the file to be read.
* It supports CSV and XLSX formats. * It supports CSV and XLSX formats.
*
* @package Box\Spout\Reader
*/ */
class ReaderFactory class ReaderFactory
{ {
@ -21,12 +19,11 @@ class ReaderFactory
* *
* @api * @api
* @param string $readerType Type of the reader to instantiate * @param string $readerType Type of the reader to instantiate
* @return ReaderInterface
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException * @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @return ReaderInterface
*/ */
public static function create($readerType) public static function create($readerType)
{ {
switch ($readerType) { switch ($readerType) {
case Type::CSV: return self::getCSVReader(); case Type::CSV: return self::getCSVReader();
case Type::XLSX: return self::getXLSXReader(); case Type::XLSX: return self::getXLSXReader();

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader;
/** /**
* Interface ReaderInterface * Interface ReaderInterface
*
* @package Box\Spout\Reader
*/ */
interface ReaderInterface interface ReaderInterface
{ {
@ -14,16 +12,16 @@ interface ReaderInterface
* that the file exists and is readable. * that the file exists and is readable.
* *
* @param string $filePath Path of the file to be read * @param string $filePath Path of the file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException * @throws \Box\Spout\Common\Exception\IOException
* @return void
*/ */
public function open($filePath); public function open($filePath);
/** /**
* Returns an iterator to iterate over sheets. * Returns an iterator to iterate over sheets.
* *
* @return \Iterator To iterate over sheets
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader * @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException If called before opening the reader
* @return \Iterator To iterate over sheets
*/ */
public function getSheetIterator(); public function getSheetIterator();

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader;
/** /**
* Interface SheetInterface * Interface SheetInterface
*
* @package Box\Spout\Reader
*/ */
interface SheetInterface interface SheetInterface
{ {

View File

@ -6,8 +6,6 @@ use Box\Spout\Reader\Exception\XMLProcessingException;
/** /**
* Trait XMLInternalErrorsHelper * Trait XMLInternalErrorsHelper
*
* @package Box\Spout\Reader\Wrapper
*/ */
trait XMLInternalErrorsHelper trait XMLInternalErrorsHelper
{ {
@ -30,8 +28,8 @@ trait XMLInternalErrorsHelper
* Throws an XMLProcessingException if an error occured. * Throws an XMLProcessingException if an error occured.
* It also always resets the "libxml_use_internal_errors" setting back to its initial value. * It also always resets the "libxml_use_internal_errors" setting back to its initial value.
* *
* @return void
* @throws \Box\Spout\Reader\Exception\XMLProcessingException * @throws \Box\Spout\Reader\Exception\XMLProcessingException
* @return void
*/ */
protected function resetXMLInternalErrorsSettingAndThrowIfXMLErrorOccured() protected function resetXMLInternalErrorsSettingAndThrowIfXMLErrorOccured()
{ {
@ -57,7 +55,7 @@ trait XMLInternalErrorsHelper
* Returns the error message for the last XML error that occured. * Returns the error message for the last XML error that occured.
* @see libxml_get_last_error * @see libxml_get_last_error
* *
* @return String|null Last XML error message or null if no error * @return string|null Last XML error message or null if no error
*/ */
private function getLastXMLErrorMessage() private function getLastXMLErrorMessage()
{ {
@ -78,5 +76,4 @@ trait XMLInternalErrorsHelper
{ {
libxml_use_internal_errors($this->initialUseInternalErrorsValue); libxml_use_internal_errors($this->initialUseInternalErrorsValue);
} }
} }

View File

@ -2,13 +2,10 @@
namespace Box\Spout\Reader\Wrapper; namespace Box\Spout\Reader\Wrapper;
/** /**
* Class XMLReader * Class XMLReader
* Wrapper around the built-in XMLReader * Wrapper around the built-in XMLReader
* @see \XMLReader * @see \XMLReader
*
* @package Box\Spout\Reader\Wrapper
*/ */
class XMLReader extends \XMLReader class XMLReader extends \XMLReader
{ {
@ -80,8 +77,8 @@ class XMLReader extends \XMLReader
* Move to next node in document * Move to next node in document
* @see \XMLReader::read * @see \XMLReader::read
* *
* @return bool TRUE on success or FALSE on failure
* @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred * @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
* @return bool TRUE on success or FALSE on failure
*/ */
public function read() public function read()
{ {
@ -98,8 +95,8 @@ class XMLReader extends \XMLReader
* Read until the element with the given name is found, or the end of the file. * Read until the element with the given name is found, or the end of the file.
* *
* @param string $nodeName Name of the node to find * @param string $nodeName Name of the node to find
* @return bool TRUE on success or FALSE on failure
* @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred * @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
* @return bool TRUE on success or FALSE on failure
*/ */
public function readUntilNodeFound($nodeName) public function readUntilNodeFound($nodeName)
{ {
@ -116,8 +113,8 @@ class XMLReader extends \XMLReader
* @see \XMLReader::next * @see \XMLReader::next
* *
* @param string|null $localName The name of the next node to move to * @param string|null $localName The name of the next node to move to
* @return bool TRUE on success or FALSE on failure
* @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred * @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
* @return bool TRUE on success or FALSE on failure
*/ */
public function next($localName = null) public function next($localName = null)
{ {
@ -136,7 +133,7 @@ class XMLReader extends \XMLReader
*/ */
public function isPositionedOnStartingNode($nodeName) public function isPositionedOnStartingNode($nodeName)
{ {
return $this->isPositionedOnNode($nodeName, XMLReader::ELEMENT); return $this->isPositionedOnNode($nodeName, self::ELEMENT);
} }
/** /**
@ -145,7 +142,7 @@ class XMLReader extends \XMLReader
*/ */
public function isPositionedOnEndingNode($nodeName) public function isPositionedOnEndingNode($nodeName)
{ {
return $this->isPositionedOnNode($nodeName, XMLReader::END_ELEMENT); return $this->isPositionedOnNode($nodeName, self::END_ELEMENT);
} }
/** /**

View File

@ -5,18 +5,16 @@ namespace Box\Spout\Reader\XLSX\Creator;
use Box\Spout\Reader\Common\Creator\EntityFactoryInterface; use Box\Spout\Reader\Common\Creator\EntityFactoryInterface;
use Box\Spout\Reader\Common\Entity\Options; use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\Common\XMLProcessor; use Box\Spout\Reader\Common\XMLProcessor;
use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\Reader\XLSX\Manager\SharedStringsManager; use Box\Spout\Reader\XLSX\Manager\SharedStringsManager;
use Box\Spout\Reader\XLSX\RowIterator; use Box\Spout\Reader\XLSX\RowIterator;
use Box\Spout\Reader\XLSX\Sheet; use Box\Spout\Reader\XLSX\Sheet;
use Box\Spout\Reader\XLSX\SheetIterator; use Box\Spout\Reader\XLSX\SheetIterator;
use Box\Spout\Reader\Wrapper\XMLReader;
use MongoDB\Driver\Manager; use MongoDB\Driver\Manager;
/** /**
* Class EntityFactory * Class EntityFactory
* Factory to create entities * Factory to create entities
*
* @package Box\Spout\Reader\XLSX\Creator
*/ */
class EntityFactory implements EntityFactoryInterface class EntityFactory implements EntityFactoryInterface
{ {
@ -45,6 +43,7 @@ class EntityFactory implements EntityFactoryInterface
public function createSheetIterator($filePath, $optionsManager, $sharedStringsManager) public function createSheetIterator($filePath, $optionsManager, $sharedStringsManager)
{ {
$sheetManager = $this->managerFactory->createSheetManager($filePath, $optionsManager, $sharedStringsManager, $this); $sheetManager = $this->managerFactory->createSheetManager($filePath, $optionsManager, $sharedStringsManager, $this);
return new SheetIterator($sheetManager); return new SheetIterator($sheetManager);
} }
@ -65,9 +64,10 @@ class EntityFactory implements EntityFactoryInterface
$sheetName, $sheetName,
$isSheetActive, $isSheetActive,
$optionsManager, $optionsManager,
$sharedStringsManager) $sharedStringsManager
{ ) {
$rowIterator = $this->createRowIterator($filePath, $sheetDataXMLFilePath, $optionsManager, $sharedStringsManager); $rowIterator = $this->createRowIterator($filePath, $sheetDataXMLFilePath, $optionsManager, $sharedStringsManager);
return new Sheet($rowIterator, $sheetIndex, $sheetName, $isSheetActive); return new Sheet($rowIterator, $sheetIndex, $sheetName, $isSheetActive);
} }

View File

@ -4,17 +4,12 @@ namespace Box\Spout\Reader\XLSX\Creator;
use Box\Spout\Common\Helper\Escaper; use Box\Spout\Common\Helper\Escaper;
use Box\Spout\Reader\XLSX\Helper\CellValueFormatter; use Box\Spout\Reader\XLSX\Helper\CellValueFormatter;
use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory;
use Box\Spout\Reader\XLSX\Manager\SharedStringsManager; use Box\Spout\Reader\XLSX\Manager\SharedStringsManager;
use Box\Spout\Reader\XLSX\Manager\SheetManager;
use Box\Spout\Reader\XLSX\Manager\StyleManager; use Box\Spout\Reader\XLSX\Manager\StyleManager;
/** /**
* Class HelperFactory * Class HelperFactory
* Factory to create helpers * Factory to create helpers
*
* @package Box\Spout\Reader\XLSX\Creator
*/ */
class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
{ {
@ -27,6 +22,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
public function createCellValueFormatter($sharedStringsManager, $styleManager, $shouldFormatDates) public function createCellValueFormatter($sharedStringsManager, $styleManager, $shouldFormatDates)
{ {
$escaper = $this->createStringsEscaper(); $escaper = $this->createStringsEscaper();
return new CellValueFormatter($sharedStringsManager, $styleManager, $shouldFormatDates, $escaper); return new CellValueFormatter($sharedStringsManager, $styleManager, $shouldFormatDates, $escaper);
} }
@ -35,7 +31,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
*/ */
public function createStringsEscaper() public function createStringsEscaper()
{ {
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ /* @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
return new Escaper\XLSX(); return new Escaper\XLSX();
} }
} }

View File

@ -7,12 +7,9 @@ use Box\Spout\Reader\XLSX\Manager\SharedStringsManager;
use Box\Spout\Reader\XLSX\Manager\SheetManager; use Box\Spout\Reader\XLSX\Manager\SheetManager;
use Box\Spout\Reader\XLSX\Manager\StyleManager; use Box\Spout\Reader\XLSX\Manager\StyleManager;
/** /**
* Class ManagerFactory * Class ManagerFactory
* Factory to create managers * Factory to create managers
*
* @package Box\Spout\Reader\XLSX\Creator
*/ */
class ManagerFactory class ManagerFactory
{ {
@ -53,6 +50,7 @@ class ManagerFactory
public function createSheetManager($filePath, $optionsManager, $sharedStringsManager, $entityFactory) public function createSheetManager($filePath, $optionsManager, $sharedStringsManager, $entityFactory)
{ {
$escaper = $this->helperFactory->createStringsEscaper(); $escaper = $this->helperFactory->createStringsEscaper();
return new SheetManager($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory); return new SheetManager($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory);
} }

View File

@ -7,8 +7,6 @@ use Box\Spout\Common\Exception\InvalidArgumentException;
/** /**
* Class CellHelper * Class CellHelper
* This class provides helper functions when working with cells * This class provides helper functions when working with cells
*
* @package Box\Spout\Reader\XLSX\Helper
*/ */
class CellHelper class CellHelper
{ {
@ -51,8 +49,8 @@ class CellHelper
* The mapping is zero based, so that A1 maps to 0, B2 maps to 1, Z13 to 25 and AA4 to 26. * The mapping is zero based, so that A1 maps to 0, B2 maps to 1, Z13 to 25 and AA4 to 26.
* *
* @param string $cellIndex The Excel cell index ('A1', 'BC13', ...) * @param string $cellIndex The Excel cell index ('A1', 'BC13', ...)
* @return int
* @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid * @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid
* @return int
*/ */
public static function getColumnIndexFromCellIndex($cellIndex) public static function getColumnIndexFromCellIndex($cellIndex)
{ {

View File

@ -8,8 +8,6 @@ use Box\Spout\Reader\XLSX\Manager\StyleManager;
/** /**
* Class CellValueFormatter * Class CellValueFormatter
* This class provides helper functions to format cell values * This class provides helper functions to format cell values
*
* @package Box\Spout\Reader\XLSX\Helper
*/ */
class CellValueFormatter class CellValueFormatter
{ {
@ -77,7 +75,7 @@ class CellValueFormatter
{ {
// Default cell type is "n" // Default cell type is "n"
$cellType = $node->getAttribute(self::XML_ATTRIBUTE_TYPE) ?: self::CELL_TYPE_NUMERIC; $cellType = $node->getAttribute(self::XML_ATTRIBUTE_TYPE) ?: self::CELL_TYPE_NUMERIC;
$cellStyleId = intval($node->getAttribute(self::XML_ATTRIBUTE_STYLE_ID)); $cellStyleId = (int) $node->getAttribute(self::XML_ATTRIBUTE_STYLE_ID);
$vNodeValue = $this->getVNodeValue($node); $vNodeValue = $this->getVNodeValue($node);
if (($vNodeValue === '') && ($cellType !== self::CELL_TYPE_INLINE_STRING)) { if (($vNodeValue === '') && ($cellType !== self::CELL_TYPE_INLINE_STRING)) {
@ -113,6 +111,7 @@ class CellValueFormatter
// for cell types having a "v" tag containing the value. // for cell types having a "v" tag containing the value.
// if not, the returned value should be empty string. // if not, the returned value should be empty string.
$vNode = $node->getElementsByTagName(self::XML_NODE_VALUE)->item(0); $vNode = $node->getElementsByTagName(self::XML_NODE_VALUE)->item(0);
return ($vNode !== null) ? $vNode->nodeValue : ''; return ($vNode !== null) ? $vNode->nodeValue : '';
} }
@ -128,6 +127,7 @@ class CellValueFormatter
// <c r="A1" t="inlineStr"><is><t>[INLINE_STRING]</t></is></c> // <c r="A1" t="inlineStr"><is><t>[INLINE_STRING]</t></is></c>
$tNode = $node->getElementsByTagName(self::XML_NODE_INLINE_STRING_VALUE)->item(0); $tNode = $node->getElementsByTagName(self::XML_NODE_INLINE_STRING_VALUE)->item(0);
$cellValue = $this->escaper->unescape($tNode->nodeValue); $cellValue = $this->escaper->unescape($tNode->nodeValue);
return $cellValue; return $cellValue;
} }
@ -141,9 +141,10 @@ class CellValueFormatter
{ {
// shared strings are formatted this way: // shared strings are formatted this way:
// <c r="A1" t="s"><v>[SHARED_STRING_INDEX]</v></c> // <c r="A1" t="s"><v>[SHARED_STRING_INDEX]</v></c>
$sharedStringIndex = intval($nodeValue); $sharedStringIndex = (int) $nodeValue;
$escapedCellValue = $this->sharedStringsManager->getStringAtIndex($sharedStringIndex); $escapedCellValue = $this->sharedStringsManager->getStringAtIndex($sharedStringIndex);
$cellValue = $this->escaper->unescape($escapedCellValue); $cellValue = $this->escaper->unescape($escapedCellValue);
return $cellValue; return $cellValue;
} }
@ -157,6 +158,7 @@ class CellValueFormatter
{ {
$escapedCellValue = trim($nodeValue); $escapedCellValue = trim($nodeValue);
$cellValue = $this->escaper->unescape($escapedCellValue); $cellValue = $this->escaper->unescape($escapedCellValue);
return $cellValue; return $cellValue;
} }
@ -175,9 +177,9 @@ class CellValueFormatter
$shouldFormatAsDate = $this->styleManager->shouldFormatNumericValueAsDate($cellStyleId); $shouldFormatAsDate = $this->styleManager->shouldFormatNumericValueAsDate($cellStyleId);
if ($shouldFormatAsDate) { if ($shouldFormatAsDate) {
$cellValue = $this->formatExcelTimestampValue(floatval($nodeValue), $cellStyleId); $cellValue = $this->formatExcelTimestampValue((float) $nodeValue, $cellStyleId);
} else { } else {
$nodeIntValue = intval($nodeValue); $nodeIntValue = (int) $nodeValue;
$nodeFloatValue = (float) $nodeValue; $nodeFloatValue = (float) $nodeValue;
$cellValue = ((float) $nodeIntValue === $nodeFloatValue) ? $nodeIntValue : $nodeFloatValue; $cellValue = ((float) $nodeIntValue === $nodeFloatValue) ? $nodeIntValue : $nodeFloatValue;
} }
@ -204,7 +206,7 @@ class CellValueFormatter
if ($nodeValue >= 1) { if ($nodeValue >= 1) {
// Values greater than 1 represent "dates". The value 1.0 representing the "base" date: 1900-01-01. // Values greater than 1 represent "dates". The value 1.0 representing the "base" date: 1900-01-01.
$cellValue = $this->formatExcelTimestampValueAsDateValue($nodeValue, $cellStyleId); $cellValue = $this->formatExcelTimestampValueAsDateValue($nodeValue, $cellStyleId);
} else if ($nodeValue >= 0) { } elseif ($nodeValue >= 0) {
// Values between 0 and 1 represent "times". // Values between 0 and 1 represent "times".
$cellValue = $this->formatExcelTimestampValueAsTimeValue($nodeValue, $cellStyleId); $cellValue = $this->formatExcelTimestampValueAsTimeValue($nodeValue, $cellStyleId);
} else { } else {
@ -262,7 +264,7 @@ class CellValueFormatter
try { try {
$dateObj = \DateTime::createFromFormat('|Y-m-d', '1899-12-31'); $dateObj = \DateTime::createFromFormat('|Y-m-d', '1899-12-31');
$dateObj->modify('+' . intval($nodeValue) . 'days'); $dateObj->modify('+' . (int) $nodeValue . 'days');
$dateObj->modify('+' . $secondsRemainder . 'seconds'); $dateObj->modify('+' . $secondsRemainder . 'seconds');
if ($this->shouldFormatDates) { if ($this->shouldFormatDates) {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Reader\XLSX\Helper;
/** /**
* Class DateFormatHelper * Class DateFormatHelper
* This class provides helper functions to format Excel dates * This class provides helper functions to format Excel dates
*
* @package Box\Spout\Reader\XLSX\Helper
*/ */
class DateFormatHelper class DateFormatHelper
{ {
@ -104,9 +102,10 @@ class DateFormatHelper
// Finally, to have the date format compatible with the DateTime::format() function, we need to escape // Finally, to have the date format compatible with the DateTime::format() function, we need to escape
// all characters that are inside double quotes (and double quotes must be removed). // all characters that are inside double quotes (and double quotes must be removed).
// For instance, ["Day " dd] should become [\D\a\y\ dd] // For instance, ["Day " dd] should become [\D\a\y\ dd]
$phpDateFormat = preg_replace_callback('/"(.+?)"/', function($matches) { $phpDateFormat = preg_replace_callback('/"(.+?)"/', function ($matches) {
$stringToEscape = $matches[1]; $stringToEscape = $matches[1];
$letters = preg_split('//u', $stringToEscape, -1, PREG_SPLIT_NO_EMPTY); $letters = preg_split('//u', $stringToEscape, -1, PREG_SPLIT_NO_EMPTY);
return '\\' . implode('\\', $letters); return '\\' . implode('\\', $letters);
}, $phpDateFormat); }, $phpDateFormat);

View File

@ -8,13 +8,11 @@ use Box\Spout\Reader\Common\Entity\Options;
/** /**
* Class OptionsManager * Class OptionsManager
* XLSX Reader options manager * XLSX Reader options manager
*
* @package Box\Spout\Reader\XLSX\Manager
*/ */
class OptionsManager extends OptionsManagerAbstract class OptionsManager extends OptionsManagerAbstract
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSupportedOptions() protected function getSupportedOptions()
{ {
@ -26,7 +24,7 @@ class OptionsManager extends OptionsManagerAbstract
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function setDefaultOptions() protected function setDefaultOptions()
{ {

View File

@ -6,8 +6,6 @@ use Box\Spout\Reader\XLSX\Creator\HelperFactory;
/** /**
* Class CachingStrategyFactory * Class CachingStrategyFactory
*
* @package Box\Spout\Reader\XLSX\Manager\SharedStringsCaching
*/ */
class CachingStrategyFactory class CachingStrategyFactory
{ {
@ -52,7 +50,6 @@ class CachingStrategyFactory
*/ */
const MAX_NUM_STRINGS_PER_TEMP_FILE = 10000; const MAX_NUM_STRINGS_PER_TEMP_FILE = 10000;
/** /**
* Returns the best caching strategy, given the number of unique shared strings * Returns the best caching strategy, given the number of unique shared strings
* and the amount of memory available. * and the amount of memory available.
@ -114,7 +111,7 @@ class CachingStrategyFactory
} }
if (preg_match('/(\d+)([bkmgt])b?/', $memoryLimitFormatted, $matches)) { if (preg_match('/(\d+)([bkmgt])b?/', $memoryLimitFormatted, $matches)) {
$amount = intval($matches[1]); $amount = (int) ($matches[1]);
$unit = $matches[2]; $unit = $matches[2];
switch ($unit) { switch ($unit) {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Reader\XLSX\Manager\SharedStringsCaching;
/** /**
* Interface CachingStrategyInterface * Interface CachingStrategyInterface
*
* @package Box\Spout\Reader\XLSX\Manager\SharedStringsCaching
*/ */
interface CachingStrategyInterface interface CachingStrategyInterface
{ {
@ -30,8 +28,8 @@ interface CachingStrategyInterface
* Returns the string located at the given index from the cache. * Returns the string located at the given index from the cache.
* *
* @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file
* @return string The shared string at the given index
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index
* @return string The shared string at the given index
*/ */
public function getStringAtIndex($sharedStringIndex); public function getStringAtIndex($sharedStringIndex);

View File

@ -11,8 +11,6 @@ use Box\Spout\Reader\XLSX\Creator\HelperFactory;
* This class implements the file-based caching strategy for shared strings. * This class implements the file-based caching strategy for shared strings.
* Shared strings are stored in small files (with a max number of strings per file). * Shared strings are stored in small files (with a max number of strings per file).
* This strategy is slower than an in-memory strategy but is used to avoid out of memory crashes. * This strategy is slower than an in-memory strategy but is used to avoid out of memory crashes.
*
* @package Box\Spout\Reader\XLSX\Manager\SharedStringsCaching
*/ */
class FileBasedStrategy implements CachingStrategyInterface class FileBasedStrategy implements CachingStrategyInterface
{ {
@ -98,7 +96,8 @@ class FileBasedStrategy implements CachingStrategyInterface
*/ */
protected function getSharedStringTempFilePath($sharedStringIndex) protected function getSharedStringTempFilePath($sharedStringIndex)
{ {
$numTempFile = intval($sharedStringIndex / $this->maxNumStringsPerTempFile); $numTempFile = (int) ($sharedStringIndex / $this->maxNumStringsPerTempFile);
return $this->tempFolder . '/sharedstrings' . $numTempFile; return $this->tempFolder . '/sharedstrings' . $numTempFile;
} }
@ -116,13 +115,12 @@ class FileBasedStrategy implements CachingStrategyInterface
} }
} }
/** /**
* Returns the string located at the given index from the cache. * Returns the string located at the given index from the cache.
* *
* @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file
* @return string The shared string at the given index
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index
* @return string The shared string at the given index
*/ */
public function getStringAtIndex($sharedStringIndex) public function getStringAtIndex($sharedStringIndex)
{ {

View File

@ -9,8 +9,6 @@ use Box\Spout\Reader\Exception\SharedStringNotFoundException;
* *
* This class implements the in-memory caching strategy for shared strings. * This class implements the in-memory caching strategy for shared strings.
* This strategy is used when the number of unique strings is low, compared to the memory available. * This strategy is used when the number of unique strings is low, compared to the memory available.
*
* @package Box\Spout\Reader\XLSX\Manager\SharedStringsCaching
*/ */
class InMemoryStrategy implements CachingStrategyInterface class InMemoryStrategy implements CachingStrategyInterface
{ {
@ -58,8 +56,8 @@ class InMemoryStrategy implements CachingStrategyInterface
* Returns the string located at the given index from the cache. * Returns the string located at the given index from the cache.
* *
* @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file
* @return string The shared string at the given index
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index
* @return string The shared string at the given index
*/ */
public function getStringAtIndex($sharedStringIndex) public function getStringAtIndex($sharedStringIndex)
{ {

View File

@ -13,8 +13,6 @@ use Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyInterface;
/** /**
* Class SharedStringsManager * Class SharedStringsManager
* This class manages the shared strings defined in the associated XML file * This class manages the shared strings defined in the associated XML file
*
* @package Box\Spout\Reader\XLSX\Manager
*/ */
class SharedStringsManager class SharedStringsManager
{ {
@ -98,8 +96,8 @@ class SharedStringsManager
* The XML file can be really big with sheets containing a lot of data. That is why * The XML file can be really big with sheets containing a lot of data. That is why
* we need to use a XML reader that provides streaming like the XMLReader library. * we need to use a XML reader that provides streaming like the XMLReader library.
* *
* @return void
* @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml can't be read * @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml can't be read
* @return void
*/ */
public function extractSharedStrings() public function extractSharedStrings()
{ {
@ -125,7 +123,6 @@ class SharedStringsManager
} }
$this->cachingStrategy->closeCache(); $this->cachingStrategy->closeCache();
} catch (XMLProcessingException $exception) { } catch (XMLProcessingException $exception) {
throw new IOException("The sharedStrings.xml file is invalid and cannot be read. [{$exception->getMessage()}]"); throw new IOException("The sharedStrings.xml file is invalid and cannot be read. [{$exception->getMessage()}]");
} }
@ -137,8 +134,8 @@ class SharedStringsManager
* Returns the shared strings unique count, as specified in <sst> tag. * Returns the shared strings unique count, as specified in <sst> tag.
* *
* @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader instance * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader instance
* @return int|null Number of unique shared strings in the sharedStrings.xml file
* @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml is invalid and can't be read * @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml is invalid and can't be read
* @return int|null Number of unique shared strings in the sharedStrings.xml file
*/ */
protected function getSharedStringsUniqueCount($xmlReader) protected function getSharedStringsUniqueCount($xmlReader)
{ {
@ -157,7 +154,7 @@ class SharedStringsManager
$uniqueCount = $xmlReader->getAttribute(self::XML_ATTRIBUTE_COUNT); $uniqueCount = $xmlReader->getAttribute(self::XML_ATTRIBUTE_COUNT);
} }
return ($uniqueCount !== null) ? intval($uniqueCount) : null; return ($uniqueCount !== null) ? (int) $uniqueCount : null;
} }
/** /**
@ -210,6 +207,7 @@ class SharedStringsManager
protected function shouldExtractTextNodeValue($textNode) protected function shouldExtractTextNodeValue($textNode)
{ {
$parentTagName = $textNode->parentNode->localName; $parentTagName = $textNode->parentNode->localName;
return ($parentTagName === self::XML_NODE_SI || $parentTagName === self::XML_NODE_R); return ($parentTagName === self::XML_NODE_SI || $parentTagName === self::XML_NODE_R);
} }
@ -222,6 +220,7 @@ class SharedStringsManager
protected function shouldPreserveWhitespace($textNode) protected function shouldPreserveWhitespace($textNode)
{ {
$spaceValue = $textNode->getAttribute(self::XML_ATTRIBUTE_XML_SPACE); $spaceValue = $textNode->getAttribute(self::XML_ATTRIBUTE_XML_SPACE);
return ($spaceValue === self::XML_ATTRIBUTE_VALUE_PRESERVE); return ($spaceValue === self::XML_ATTRIBUTE_VALUE_PRESERVE);
} }
@ -229,8 +228,8 @@ class SharedStringsManager
* Returns the shared string at the given index, using the previously chosen caching strategy. * Returns the shared string at the given index, using the previously chosen caching strategy.
* *
* @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file
* @return string The shared string at the given index
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index
* @return string The shared string at the given index
*/ */
public function getStringAtIndex($sharedStringIndex) public function getStringAtIndex($sharedStringIndex)
{ {

View File

@ -2,15 +2,12 @@
namespace Box\Spout\Reader\XLSX\Manager; namespace Box\Spout\Reader\XLSX\Manager;
use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\Reader\XLSX\Creator\EntityFactory; use Box\Spout\Reader\XLSX\Creator\EntityFactory;
use Box\Spout\Reader\XLSX\Sheet; use Box\Spout\Reader\XLSX\Sheet;
/** /**
* Class SheetManager * Class SheetManager
* This class manages XLSX sheets * This class manages XLSX sheets
*
* @package Box\Spout\Reader\XLSX\Manager
*/ */
class SheetManager class SheetManager
{ {
@ -55,6 +52,7 @@ class SheetManager
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings * @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings
* @param \Box\Spout\Common\Helper\Escaper\XLSX $escaper Used to unescape XML data * @param \Box\Spout\Common\Helper\Escaper\XLSX $escaper Used to unescape XML data
* @param EntityFactory $entityFactory Factory to create entities * @param EntityFactory $entityFactory Factory to create entities
* @param mixed $sharedStringsManager
*/ */
public function __construct($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory) public function __construct($filePath, $optionsManager, $sharedStringsManager, $escaper, $entityFactory)
{ {
@ -85,11 +83,11 @@ class SheetManager
// The "workbookView" node is located before "sheet" nodes, ensuring that // The "workbookView" node is located before "sheet" nodes, ensuring that
// the active sheet is known before parsing sheets data. // the active sheet is known before parsing sheets data.
$activeSheetIndex = (int) $xmlReader->getAttribute(self::XML_ATTRIBUTE_ACTIVE_TAB); $activeSheetIndex = (int) $xmlReader->getAttribute(self::XML_ATTRIBUTE_ACTIVE_TAB);
} else if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_SHEET)) { } elseif ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_SHEET)) {
$isSheetActive = ($sheetIndex === $activeSheetIndex); $isSheetActive = ($sheetIndex === $activeSheetIndex);
$sheets[] = $this->getSheetFromSheetXMLNode($xmlReader, $sheetIndex, $isSheetActive); $sheets[] = $this->getSheetFromSheetXMLNode($xmlReader, $sheetIndex, $isSheetActive);
$sheetIndex++; $sheetIndex++;
} else if ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_SHEETS)) { } elseif ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_SHEETS)) {
// stop reading once all sheets have been read // stop reading once all sheets have been read
break; break;
} }

View File

@ -7,8 +7,6 @@ use Box\Spout\Reader\XLSX\Creator\EntityFactory;
/** /**
* Class StyleManager * Class StyleManager
* This class manages XLSX styles * This class manages XLSX styles
*
* @package Box\Spout\Reader\XLSX\Manager
*/ */
class StyleManager class StyleManager
{ {
@ -118,8 +116,7 @@ class StyleManager
while ($xmlReader->read()) { while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_NUM_FMTS)) { if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_NUM_FMTS)) {
$this->extractNumberFormats($xmlReader); $this->extractNumberFormats($xmlReader);
} elseif ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_CELL_XFS)) {
} else if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_CELL_XFS)) {
$this->extractStyleAttributes($xmlReader); $this->extractStyleAttributes($xmlReader);
} }
} }
@ -140,10 +137,10 @@ class StyleManager
{ {
while ($xmlReader->read()) { while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_NUM_FMT)) { if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_NUM_FMT)) {
$numFmtId = intval($xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_FMT_ID)); $numFmtId = (int) ($xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_FMT_ID));
$formatCode = $xmlReader->getAttribute(self::XML_ATTRIBUTE_FORMAT_CODE); $formatCode = $xmlReader->getAttribute(self::XML_ATTRIBUTE_FORMAT_CODE);
$this->customNumberFormats[$numFmtId] = $formatCode; $this->customNumberFormats[$numFmtId] = $formatCode;
} else if ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_NUM_FMTS)) { } elseif ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_NUM_FMTS)) {
// Once done reading "numFmts" node's children // Once done reading "numFmts" node's children
break; break;
} }
@ -163,16 +160,16 @@ class StyleManager
while ($xmlReader->read()) { while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_XF)) { if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_XF)) {
$numFmtId = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_FMT_ID); $numFmtId = $xmlReader->getAttribute(self::XML_ATTRIBUTE_NUM_FMT_ID);
$normalizedNumFmtId = ($numFmtId !== null) ? intval($numFmtId) : null; $normalizedNumFmtId = ($numFmtId !== null) ? (int) $numFmtId : null;
$applyNumberFormat = $xmlReader->getAttribute(self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT); $applyNumberFormat = $xmlReader->getAttribute(self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT);
$normalizedApplyNumberFormat = ($applyNumberFormat !== null) ? !!$applyNumberFormat : null; $normalizedApplyNumberFormat = ($applyNumberFormat !== null) ? (bool) $applyNumberFormat : null;
$this->stylesAttributes[] = [ $this->stylesAttributes[] = [
self::XML_ATTRIBUTE_NUM_FMT_ID => $normalizedNumFmtId, self::XML_ATTRIBUTE_NUM_FMT_ID => $normalizedNumFmtId,
self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT => $normalizedApplyNumberFormat, self::XML_ATTRIBUTE_APPLY_NUMBER_FORMAT => $normalizedApplyNumberFormat,
]; ];
} else if ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_CELL_XFS)) { } elseif ($xmlReader->isPositionedOnEndingNode(self::XML_NODE_CELL_XFS)) {
// Once done reading "cellXfs" node's children // Once done reading "cellXfs" node's children
break; break;
} }

View File

@ -14,8 +14,6 @@ use Box\Spout\Reader\XLSX\Creator\ManagerFactory;
/** /**
* Class Reader * Class Reader
* This class provides support to read data from a XLSX file * This class provides support to read data from a XLSX file
*
* @package Box\Spout\Reader\XLSX
*/ */
class Reader extends ReaderAbstract class Reader extends ReaderAbstract
{ {
@ -31,7 +29,6 @@ class Reader extends ReaderAbstract
/** @var SheetIterator To iterator over the XLSX sheets */ /** @var SheetIterator To iterator over the XLSX sheets */
protected $sheetIterator; protected $sheetIterator;
/** /**
* @param OptionsManagerInterface $optionsManager * @param OptionsManagerInterface $optionsManager
* @param GlobalFunctionsHelper $globalFunctionsHelper * @param GlobalFunctionsHelper $globalFunctionsHelper
@ -42,8 +39,8 @@ class Reader extends ReaderAbstract
OptionsManagerInterface $optionsManager, OptionsManagerInterface $optionsManager,
GlobalFunctionsHelper $globalFunctionsHelper, GlobalFunctionsHelper $globalFunctionsHelper,
EntityFactoryInterface $entityFactory, EntityFactoryInterface $entityFactory,
ManagerFactory $managerFactory) ManagerFactory $managerFactory
{ ) {
parent::__construct($optionsManager, $globalFunctionsHelper, $entityFactory); parent::__construct($optionsManager, $globalFunctionsHelper, $entityFactory);
$this->managerFactory = $managerFactory; $this->managerFactory = $managerFactory;
} }
@ -55,6 +52,7 @@ class Reader extends ReaderAbstract
public function setTempFolder($tempFolder) public function setTempFolder($tempFolder)
{ {
$this->optionsManager->setOption(Options::TEMP_FOLDER, $tempFolder); $this->optionsManager->setOption(Options::TEMP_FOLDER, $tempFolder);
return $this; return $this;
} }
@ -74,9 +72,9 @@ class Reader extends ReaderAbstract
* and fetches all the available sheets. * and fetches all the available sheets.
* *
* @param string $filePath Path of the file to be read * @param string $filePath Path of the file to be read
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the file at the given path or its content cannot be read * @throws \Box\Spout\Common\Exception\IOException If the file at the given path or its content cannot be read
* @throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file * @throws \Box\Spout\Reader\Exception\NoSheetsFoundException If there are no sheets in the file
* @return void
*/ */
protected function openReader($filePath) protected function openReader($filePath)
{ {

View File

@ -3,20 +3,15 @@
namespace Box\Spout\Reader\XLSX; namespace Box\Spout\Reader\XLSX;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Reader\Common\Entity\Options; use Box\Spout\Reader\Common\XMLProcessor;
use Box\Spout\Reader\Exception\XMLProcessingException; use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\Reader\IteratorInterface; use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\Wrapper\XMLReader; use Box\Spout\Reader\Wrapper\XMLReader;
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
use Box\Spout\Reader\XLSX\Creator\HelperFactory;
use Box\Spout\Reader\XLSX\Helper\CellHelper; use Box\Spout\Reader\XLSX\Helper\CellHelper;
use Box\Spout\Reader\Common\XMLProcessor;
use Box\Spout\Reader\XLSX\Helper\CellValueFormatter; use Box\Spout\Reader\XLSX\Helper\CellValueFormatter;
/** /**
* Class RowIterator * Class RowIterator
*
* @package Box\Spout\Reader\XLSX
*/ */
class RowIterator implements IteratorInterface class RowIterator implements IteratorInterface
{ {
@ -57,7 +52,7 @@ class RowIterator implements IteratorInterface
protected $currentlyProcessedRowData = []; protected $currentlyProcessedRowData = [];
/** @var array|null Buffer used to store the row data, while checking if there are more rows to read */ /** @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 */ /** @var bool Indicates whether all rows have been read */
protected $hasReachedEndOfFile = false; protected $hasReachedEndOfFile = false;
@ -116,10 +111,10 @@ class RowIterator implements IteratorInterface
* Rewind the Iterator to the first element. * Rewind the Iterator to the first element.
* Initializes the XMLReader object that reads the associated sheet data. * Initializes the XMLReader object that reads the associated sheet data.
* The XMLReader is configured to be safe from billion laughs attack. * The XMLReader is configured to be safe from billion laughs attack.
* @link http://php.net/manual/en/iterator.rewind.php * @see http://php.net/manual/en/iterator.rewind.php
* *
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read * @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
* @return void
*/ */
public function rewind() public function rewind()
{ {
@ -141,7 +136,7 @@ class RowIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -152,11 +147,11 @@ class RowIterator implements IteratorInterface
/** /**
* Move forward to next element. Reads data describing the next unprocessed row. * Move forward to next element. Reads data describing 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\Reader\Exception\SharedStringNotFoundException If a shared string was not found * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML * @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/ */
public function next() public function next()
{ {
@ -191,9 +186,9 @@ class RowIterator implements IteratorInterface
} }
/** /**
* @return void
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML * @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/ */
protected function readDataForNextRow() protected function readDataForNextRow()
{ {
@ -240,7 +235,7 @@ class RowIterator implements IteratorInterface
$spans = $xmlReader->getAttribute(self::XML_ATTRIBUTE_SPANS); // returns '1:5' for instance $spans = $xmlReader->getAttribute(self::XML_ATTRIBUTE_SPANS); // returns '1:5' for instance
if ($spans) { if ($spans) {
list(, $numberOfColumnsForRow) = explode(':', $spans); list(, $numberOfColumnsForRow) = explode(':', $spans);
$numberOfColumnsForRow = intval($numberOfColumnsForRow); $numberOfColumnsForRow = (int) $numberOfColumnsForRow;
} }
$this->currentlyProcessedRowData = ($numberOfColumnsForRow !== 0) ? array_fill(0, $numberOfColumnsForRow, '') : []; $this->currentlyProcessedRowData = ($numberOfColumnsForRow !== 0) ? array_fill(0, $numberOfColumnsForRow, '') : [];
@ -300,8 +295,8 @@ class RowIterator implements IteratorInterface
/** /**
* @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object, positioned on a "<row>" node * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object, positioned on a "<row>" node
* @return int Row index
* @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid * @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid
* @return int Row index
*/ */
protected function getRowIndex($xmlReader) protected function getRowIndex($xmlReader)
{ {
@ -309,14 +304,14 @@ class RowIterator implements IteratorInterface
$currentRowIndex = $xmlReader->getAttribute(self::XML_ATTRIBUTE_ROW_INDEX); $currentRowIndex = $xmlReader->getAttribute(self::XML_ATTRIBUTE_ROW_INDEX);
return ($currentRowIndex !== null) ? return ($currentRowIndex !== null) ?
intval($currentRowIndex) : (int) $currentRowIndex :
$this->lastRowIndexProcessed + 1; $this->lastRowIndexProcessed + 1;
} }
/** /**
* @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object, positioned on a "<c>" node * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object, positioned on a "<c>" node
* @return int Column index
* @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid * @throws \Box\Spout\Common\Exception\InvalidArgumentException When the given cell index is invalid
* @return int Column index
*/ */
protected function getColumnIndex($xmlReader) protected function getColumnIndex($xmlReader)
{ {
@ -350,7 +345,7 @@ class RowIterator implements IteratorInterface
/** /**
* Return the current element, either an empty row or from the buffer. * Return the current element, either an empty row or from the buffer.
* @link http://php.net/manual/en/iterator.current.php * @see http://php.net/manual/en/iterator.current.php
* *
* @return array|null * @return array|null
*/ */
@ -375,7 +370,7 @@ class RowIterator implements IteratorInterface
/** /**
* Return the key of the current element. Here, the row index. * Return the key of the current element. Here, the row index.
* @link http://php.net/manual/en/iterator.key.php * @see http://php.net/manual/en/iterator.key.php
* *
* @return int * @return int
*/ */
@ -389,7 +384,6 @@ class RowIterator implements IteratorInterface
$this->numReadRows; $this->numReadRows;
} }
/** /**
* Cleans up what was created to iterate over the object. * Cleans up what was created to iterate over the object.
* *

View File

@ -3,13 +3,10 @@
namespace Box\Spout\Reader\XLSX; namespace Box\Spout\Reader\XLSX;
use Box\Spout\Reader\SheetInterface; use Box\Spout\Reader\SheetInterface;
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
/** /**
* Class Sheet * Class Sheet
* Represents a sheet within a XLSX file * Represents a sheet within a XLSX file
*
* @package Box\Spout\Reader\XLSX
*/ */
class Sheet implements SheetInterface class Sheet implements SheetInterface
{ {

View File

@ -2,15 +2,13 @@
namespace Box\Spout\Reader\XLSX; namespace Box\Spout\Reader\XLSX;
use Box\Spout\Reader\Exception\NoSheetsFoundException;
use Box\Spout\Reader\IteratorInterface; use Box\Spout\Reader\IteratorInterface;
use Box\Spout\Reader\XLSX\Manager\SheetManager; use Box\Spout\Reader\XLSX\Manager\SheetManager;
use Box\Spout\Reader\Exception\NoSheetsFoundException;
/** /**
* Class SheetIterator * Class SheetIterator
* Iterate over XLSX sheet. * Iterate over XLSX sheet.
*
* @package Box\Spout\Reader\XLSX
*/ */
class SheetIterator implements IteratorInterface class SheetIterator implements IteratorInterface
{ {
@ -36,7 +34,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Rewind the Iterator to the first element * 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 * @return void
*/ */
@ -47,7 +45,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Checks if current position is valid * 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 * @return bool
*/ */
@ -58,7 +56,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Move forward to next element * 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 * @return void
*/ */
@ -75,7 +73,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the current element * 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\XLSX\Sheet * @return \Box\Spout\Reader\XLSX\Sheet
*/ */
@ -86,7 +84,7 @@ class SheetIterator implements IteratorInterface
/** /**
* Return the key of the current element * 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 * @return int
*/ */

View File

@ -2,19 +2,17 @@
namespace Box\Spout\Writer\CSV\Manager; namespace Box\Spout\Writer\CSV\Manager;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Common\Manager\OptionsManagerAbstract; use Box\Spout\Common\Manager\OptionsManagerAbstract;
use Box\Spout\Writer\Common\Entity\Options;
/** /**
* Class OptionsManager * Class OptionsManager
* CSV Writer options manager * CSV Writer options manager
*
* @package Box\Spout\Writer\CSV\Manager
*/ */
class OptionsManager extends OptionsManagerAbstract class OptionsManager extends OptionsManagerAbstract
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSupportedOptions() protected function getSupportedOptions()
{ {
@ -26,7 +24,7 @@ class OptionsManager extends OptionsManagerAbstract
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function setDefaultOptions() protected function setDefaultOptions()
{ {

View File

@ -2,16 +2,14 @@
namespace Box\Spout\Writer\CSV; namespace Box\Spout\Writer\CSV;
use Box\Spout\Writer\WriterAbstract;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\EncodingHelper; use Box\Spout\Common\Helper\EncodingHelper;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\WriterAbstract;
/** /**
* Class Writer * Class Writer
* This class provides support to write data to CSV files * This class provides support to write data to CSV files
*
* @package Box\Spout\Writer\CSV
*/ */
class Writer extends WriterAbstract class Writer extends WriterAbstract
{ {
@ -34,6 +32,7 @@ class Writer extends WriterAbstract
public function setFieldDelimiter($fieldDelimiter) public function setFieldDelimiter($fieldDelimiter)
{ {
$this->optionsManager->setOption(Options::FIELD_DELIMITER, $fieldDelimiter); $this->optionsManager->setOption(Options::FIELD_DELIMITER, $fieldDelimiter);
return $this; return $this;
} }
@ -47,6 +46,7 @@ class Writer extends WriterAbstract
public function setFieldEnclosure($fieldEnclosure) public function setFieldEnclosure($fieldEnclosure)
{ {
$this->optionsManager->setOption(Options::FIELD_ENCLOSURE, $fieldEnclosure); $this->optionsManager->setOption(Options::FIELD_ENCLOSURE, $fieldEnclosure);
return $this; return $this;
} }
@ -60,6 +60,7 @@ class Writer extends WriterAbstract
public function setShouldAddBOM($shouldAddBOM) public function setShouldAddBOM($shouldAddBOM)
{ {
$this->optionsManager->setOption(Options::SHOULD_ADD_BOM, (bool) $shouldAddBOM); $this->optionsManager->setOption(Options::SHOULD_ADD_BOM, (bool) $shouldAddBOM);
return $this; return $this;
} }
@ -82,8 +83,8 @@ class Writer extends WriterAbstract
* @param array $dataRow Array containing data to be written. * @param array $dataRow Array containing data to be written.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param \Box\Spout\Writer\Common\Entity\Style\Style $style Ignored here since CSV does not support styling. * @param \Box\Spout\Writer\Common\Entity\Style\Style $style Ignored here since CSV does not support styling.
* @return void
* @throws \Box\Spout\Common\Exception\IOException If unable to write data * @throws \Box\Spout\Common\Exception\IOException If unable to write data
* @return void
*/ */
protected function addRowToWriter(array $dataRow, $style) protected function addRowToWriter(array $dataRow, $style)
{ {

View File

@ -11,8 +11,6 @@ use Box\Spout\Writer\Common\Manager\SheetManager;
/** /**
* Class EntityFactory * Class EntityFactory
* Factory to create entities * Factory to create entities
*
* @package Box\Spout\Writer\Common\Creator
*/ */
class EntityFactory class EntityFactory
{ {

View File

@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
/** /**
* Interface ManagerFactoryInterface * Interface ManagerFactoryInterface
*
* @package Box\Spout\Writer\Common\Creator
*/ */
interface ManagerFactoryInterface interface ManagerFactoryInterface
{ {

View File

@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Entity\Style\Color;
/** /**
* Class BorderBuilder * Class BorderBuilder
*
* @package \Box\Spout\Writer\Common\Creator\Style
*/ */
class BorderBuilder class BorderBuilder
{ {
@ -32,6 +30,7 @@ class BorderBuilder
public function setBorderTop($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) public function setBorderTop($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
{ {
$this->border->addPart(new BorderPart(Border::TOP, $color, $width, $style)); $this->border->addPart(new BorderPart(Border::TOP, $color, $width, $style));
return $this; return $this;
} }
@ -44,6 +43,7 @@ class BorderBuilder
public function setBorderRight($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) public function setBorderRight($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
{ {
$this->border->addPart(new BorderPart(Border::RIGHT, $color, $width, $style)); $this->border->addPart(new BorderPart(Border::RIGHT, $color, $width, $style));
return $this; return $this;
} }
@ -56,6 +56,7 @@ class BorderBuilder
public function setBorderBottom($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) public function setBorderBottom($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
{ {
$this->border->addPart(new BorderPart(Border::BOTTOM, $color, $width, $style)); $this->border->addPart(new BorderPart(Border::BOTTOM, $color, $width, $style));
return $this; return $this;
} }
@ -68,6 +69,7 @@ class BorderBuilder
public function setBorderLeft($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) public function setBorderLeft($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
{ {
$this->border->addPart(new BorderPart(Border::LEFT, $color, $width, $style)); $this->border->addPart(new BorderPart(Border::LEFT, $color, $width, $style));
return $this; return $this;
} }

View File

@ -8,8 +8,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Class StyleBuilder * Class StyleBuilder
* Builder to create new styles * Builder to create new styles
*
* @package Box\Spout\Writer\Common\Creator\Style
*/ */
class StyleBuilder class StyleBuilder
{ {
@ -33,6 +31,7 @@ class StyleBuilder
public function setFontBold() public function setFontBold()
{ {
$this->style->setFontBold(); $this->style->setFontBold();
return $this; return $this;
} }
@ -45,6 +44,7 @@ class StyleBuilder
public function setFontItalic() public function setFontItalic()
{ {
$this->style->setFontItalic(); $this->style->setFontItalic();
return $this; return $this;
} }
@ -57,6 +57,7 @@ class StyleBuilder
public function setFontUnderline() public function setFontUnderline()
{ {
$this->style->setFontUnderline(); $this->style->setFontUnderline();
return $this; return $this;
} }
@ -69,6 +70,7 @@ class StyleBuilder
public function setFontStrikethrough() public function setFontStrikethrough()
{ {
$this->style->setFontStrikethrough(); $this->style->setFontStrikethrough();
return $this; return $this;
} }
@ -82,6 +84,7 @@ class StyleBuilder
public function setFontSize($fontSize) public function setFontSize($fontSize)
{ {
$this->style->setFontSize($fontSize); $this->style->setFontSize($fontSize);
return $this; return $this;
} }
@ -95,6 +98,7 @@ class StyleBuilder
public function setFontColor($fontColor) public function setFontColor($fontColor)
{ {
$this->style->setFontColor($fontColor); $this->style->setFontColor($fontColor);
return $this; return $this;
} }
@ -108,6 +112,7 @@ class StyleBuilder
public function setFontName($fontName) public function setFontName($fontName)
{ {
$this->style->setFontName($fontName); $this->style->setFontName($fontName);
return $this; return $this;
} }
@ -121,6 +126,7 @@ class StyleBuilder
public function setShouldWrapText($shouldWrap = true) public function setShouldWrapText($shouldWrap = true)
{ {
$this->style->setShouldWrapText($shouldWrap); $this->style->setShouldWrapText($shouldWrap);
return $this; return $this;
} }
@ -133,6 +139,7 @@ class StyleBuilder
public function setBorder(Border $border) public function setBorder(Border $border)
{ {
$this->style->setBorder($border); $this->style->setBorder($border);
return $this; return $this;
} }
@ -146,6 +153,7 @@ class StyleBuilder
public function setBackgroundColor($color) public function setBackgroundColor($color)
{ {
$this->style->setBackgroundColor($color); $this->style->setBackgroundColor($color);
return $this; return $this;
} }

View File

@ -6,8 +6,6 @@ use Box\Spout\Writer\Common\Helper\CellHelper;
/** /**
* Class Cell * Class Cell
*
* @package Box\Spout\Writer\Common\Entity
*/ */
class Cell class Cell
{ {
@ -46,13 +44,13 @@ class Cell
* The value of this cell * The value of this cell
* @var mixed|null * @var mixed|null
*/ */
protected $value = null; protected $value;
/** /**
* The cell type * The cell type
* @var int|null * @var int|null
*/ */
protected $type = null; protected $type;
/** /**
* Cell constructor. * Cell constructor.
@ -165,6 +163,6 @@ class Cell
*/ */
public function __toString() public function __toString()
{ {
return (string)$this->value; return (string) $this->value;
} }
} }

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity;
/** /**
* Class Options * Class Options
* Writers' options holder * Writers' options holder
*
* @package Box\Spout\Writer\Common\Entity
*/ */
abstract class Options abstract class Options
{ {

View File

@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Manager\SheetManager;
/** /**
* Class Sheet * Class Sheet
* External representation of a worksheet * External representation of a worksheet
*
* @package Box\Spout\Writer\Common\Entity
*/ */
class Sheet class Sheet
{ {
@ -77,8 +75,8 @@ class Sheet
* *
* @api * @api
* @param string $name Name of the sheet * @param string $name Name of the sheet
* @return Sheet
* @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid. * @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid.
* @return Sheet
*/ */
public function setName($name) public function setName($name)
{ {

View File

@ -4,8 +4,6 @@ namespace Box\Spout\Writer\Common\Entity\Style;
/** /**
* Class Border * Class Border
*
* @package \Box\Spout\Writer\Common\Entity\Style
*/ */
class Border class Border
{ {
@ -37,7 +35,7 @@ class Border
/** /**
* @param string $name The name of the border part * @param string $name The name of the border part
* @return null|BorderPart * @return BorderPart|null
*/ */
public function getPart($name) public function getPart($name)
{ {
@ -81,6 +79,7 @@ class Border
public function addPart(BorderPart $borderPart) public function addPart(BorderPart $borderPart)
{ {
$this->parts[$borderPart->getName()] = $borderPart; $this->parts[$borderPart->getName()] = $borderPart;
return $this; return $this;
} }
} }

View File

@ -8,8 +8,6 @@ use Box\Spout\Writer\Exception\Border\InvalidWidthException;
/** /**
* Class BorderPart * Class BorderPart
*
* @package \Box\Spout\Writer\Common\Entity\Style
*/ */
class BorderPart class BorderPart
{ {
@ -41,7 +39,7 @@ class BorderPart
'solid', 'solid',
'dashed', 'dashed',
'dotted', 'dotted',
'double' 'double',
]; ];
/** /**

View File

@ -7,8 +7,6 @@ use Box\Spout\Writer\Exception\InvalidColorException;
/** /**
* Class Color * Class Color
* This class provides constants and functions to work with colors * This class provides constants and functions to work with colors
*
* @package Box\Spout\Writer\Common\Entity\Style
*/ */
class Color class Color
{ {
@ -52,8 +50,8 @@ class Color
* Throws an exception is the color component value is outside of bounds (0 - 255) * Throws an exception is the color component value is outside of bounds (0 - 255)
* *
* @param int $colorComponent * @param int $colorComponent
* @return void
* @throws \Box\Spout\Writer\Exception\InvalidColorException * @throws \Box\Spout\Writer\Exception\InvalidColorException
* @return void
*/ */
protected static function throwIfInvalidColorComponentValue($colorComponent) protected static function throwIfInvalidColorComponentValue($colorComponent)
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity\Style;
/** /**
* Class Style * Class Style
* Represents a style to be applied to a cell * Represents a style to be applied to a cell
*
* @package Box\Spout\Writer\Common\Entity\Style
*/ */
class Style class Style
{ {
@ -16,7 +14,7 @@ class Style
const DEFAULT_FONT_NAME = 'Arial'; const DEFAULT_FONT_NAME = 'Arial';
/** @var int|null Style ID */ /** @var int|null Style ID */
private $id = null; private $id;
/** @var bool Whether the font should be bold */ /** @var bool Whether the font should be bold */
private $fontBold = false; private $fontBold = false;
@ -62,18 +60,17 @@ class Style
private $hasSetWrapText = false; private $hasSetWrapText = false;
/** @var Border */ /** @var Border */
private $border = null; private $border;
/** @var bool Whether border properties should be applied */ /** @var bool Whether border properties should be applied */
private $shouldApplyBorder = false; private $shouldApplyBorder = false;
/** @var string Background color */ /** @var string Background color */
private $backgroundColor = null; private $backgroundColor;
/** @var bool */ /** @var bool */
private $hasSetBackgroundColor = false; private $hasSetBackgroundColor = false;
/** /**
* @return int|null * @return int|null
*/ */
@ -89,6 +86,7 @@ class Style
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@ -108,6 +106,7 @@ class Style
{ {
$this->shouldApplyBorder = true; $this->shouldApplyBorder = true;
$this->border = $border; $this->border = $border;
return $this; return $this;
} }
@ -135,6 +134,7 @@ class Style
$this->fontBold = true; $this->fontBold = true;
$this->hasSetFontBold = true; $this->hasSetFontBold = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -162,6 +162,7 @@ class Style
$this->fontItalic = true; $this->fontItalic = true;
$this->hasSetFontItalic = true; $this->hasSetFontItalic = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -189,6 +190,7 @@ class Style
$this->fontUnderline = true; $this->fontUnderline = true;
$this->hasSetFontUnderline = true; $this->hasSetFontUnderline = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -216,6 +218,7 @@ class Style
$this->fontStrikethrough = true; $this->fontStrikethrough = true;
$this->hasSetFontStrikethrough = true; $this->hasSetFontStrikethrough = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -244,6 +247,7 @@ class Style
$this->fontSize = $fontSize; $this->fontSize = $fontSize;
$this->hasSetFontSize = true; $this->hasSetFontSize = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -274,6 +278,7 @@ class Style
$this->fontColor = $fontColor; $this->fontColor = $fontColor;
$this->hasSetFontColor = true; $this->hasSetFontColor = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -302,6 +307,7 @@ class Style
$this->fontName = $fontName; $this->fontName = $fontName;
$this->hasSetFontName = true; $this->hasSetFontName = true;
$this->shouldApplyFont = true; $this->shouldApplyFont = true;
return $this; return $this;
} }
@ -329,6 +335,7 @@ class Style
{ {
$this->shouldWrapText = $shouldWrap; $this->shouldWrapText = $shouldWrap;
$this->hasSetWrapText = true; $this->hasSetWrapText = true;
return $this; return $this;
} }
@ -357,6 +364,7 @@ class Style
{ {
$this->hasSetBackgroundColor = true; $this->hasSetBackgroundColor = true;
$this->backgroundColor = $color; $this->backgroundColor = $color;
return $this; return $this;
} }
@ -369,7 +377,6 @@ class Style
} }
/** /**
*
* @return bool Whether the background color should be applied * @return bool Whether the background color should be applied
*/ */
public function shouldApplyBackgroundColor() public function shouldApplyBackgroundColor()

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Entity;
/** /**
* Class Workbook * Class Workbook
* Entity describing a workbook * Entity describing a workbook
*
* @package Box\Spout\Writer\Common\Entity
*/ */
class Workbook class Workbook
{ {

View File

@ -5,15 +5,13 @@ namespace Box\Spout\Writer\Common\Entity;
/** /**
* Class Worksheet * Class Worksheet
* Entity describing a Worksheet * Entity describing a Worksheet
*
* @package Box\Spout\Writer\Common\Entity
*/ */
class Worksheet class Worksheet
{ {
/** @var string Path to the XML file that will contain the sheet data */ /** @var string Path to the XML file that will contain the sheet data */
private $filePath; private $filePath;
/** @var Resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */ /** @var resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
private $filePointer; private $filePointer;
/** @var Sheet The "external" sheet */ /** @var Sheet The "external" sheet */
@ -49,7 +47,7 @@ class Worksheet
} }
/** /**
* @return Resource * @return resource
*/ */
public function getFilePointer() public function getFilePointer()
{ {
@ -57,7 +55,7 @@ class Worksheet
} }
/** /**
* @param Resource $filePointer * @param resource $filePointer
*/ */
public function setFilePointer($filePointer) public function setFilePointer($filePointer)
{ {

View File

@ -5,8 +5,6 @@ namespace Box\Spout\Writer\Common\Helper;
/** /**
* Class CellHelper * Class CellHelper
* This class provides helper functions when working with cells * This class provides helper functions when working with cells
*
* @package Box\Spout\Writer\Common\Helper
*/ */
class CellHelper class CellHelper
{ {
@ -36,8 +34,7 @@ class CellHelper
$cellIndex = chr($capitalAAsciiValue + $modulus) . $cellIndex; $cellIndex = chr($capitalAAsciiValue + $modulus) . $cellIndex;
// substracting 1 because it's zero-based // substracting 1 because it's zero-based
$columnIndex = intval($columnIndex / 26) - 1; $columnIndex = (int) ($columnIndex / 26) - 1;
} while ($columnIndex >= 0); } while ($columnIndex >= 0);
self::$columnIndexToCellIndexCache[$originalColumnIndex] = $cellIndex; self::$columnIndexToCellIndexCache[$originalColumnIndex] = $cellIndex;
@ -74,6 +71,7 @@ class CellHelper
public static function isNumeric($value) public static function isNumeric($value)
{ {
$valueType = gettype($value); $valueType = gettype($value);
return ($valueType === 'integer' || $valueType === 'double'); return ($valueType === 'integer' || $valueType === 'double');
} }

View File

@ -2,22 +2,20 @@
namespace Box\Spout\Writer\Common\Helper; namespace Box\Spout\Writer\Common\Helper;
use \Box\Spout\Common\Helper\FileSystemHelperInterface; use Box\Spout\Common\Helper\FileSystemHelperInterface;
/** /**
* Class FileSystemHelperInterface * Class FileSystemHelperInterface
* This interface describes helper functions to help with the file system operations * This interface describes helper functions to help with the file system operations
* like files/folders creation & deletion * like files/folders creation & deletion
*
* @package Box\Spout\Writer\Common\Helper
*/ */
interface FileSystemWithRootFolderHelperInterface extends FileSystemHelperInterface interface FileSystemWithRootFolderHelperInterface extends FileSystemHelperInterface
{ {
/** /**
* Creates all the folders needed to create a spreadsheet, as well as the files that won't change. * Creates all the folders needed to create a spreadsheet, as well as the files that won't change.
* *
* @return void
* @throws \Box\Spout\Common\Exception\IOException If unable to create at least one of the base folders * @throws \Box\Spout\Common\Exception\IOException If unable to create at least one of the base folders
* @return void
*/ */
public function createBaseFilesAndFolders(); public function createBaseFilesAndFolders();

View File

@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Creator\EntityFactory;
/** /**
* Class ZipHelper * Class ZipHelper
* This class provides helper functions to create zip files * This class provides helper functions to create zip files
*
* @package Box\Spout\Writer\Common\Helper
*/ */
class ZipHelper class ZipHelper
{ {
@ -40,7 +38,7 @@ class ZipHelper
$zip = $this->entityFactory->createZipArchive(); $zip = $this->entityFactory->createZipArchive();
$zipFilePath = $tmpFolderPath . self::ZIP_EXTENSION; $zipFilePath = $tmpFolderPath . self::ZIP_EXTENSION;
$zip->open($zipFilePath, \ZipArchive::CREATE|\ZipArchive::OVERWRITE); $zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
return $zip; return $zip;
} }
@ -184,6 +182,7 @@ class ZipHelper
protected function getNormalizedRealPath($path) protected function getNormalizedRealPath($path)
{ {
$realPath = realpath($path); $realPath = realpath($path);
return str_replace(DIRECTORY_SEPARATOR, '/', $realPath); return str_replace(DIRECTORY_SEPARATOR, '/', $realPath);
} }

View File

@ -9,8 +9,6 @@ use Box\Spout\Writer\Exception\InvalidSheetNameException;
/** /**
* Class SheetManager * Class SheetManager
* Sheet manager * Sheet manager
*
* @package Box\Spout\Writer\Common\Manager
*/ */
class SheetManager class SheetManager
{ {
@ -42,8 +40,8 @@ class SheetManager
* *
* @param string $name * @param string $name
* @param Sheet $sheet The sheet whose future name is checked * @param Sheet $sheet The sheet whose future name is checked
* @return void
* @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid. * @throws \Box\Spout\Writer\Exception\InvalidSheetNameException If the sheet's name is invalid.
* @return void
*/ */
public function throwIfNameIsInvalid($name, Sheet $sheet) public function throwIfNameIsInvalid($name, Sheet $sheet)
{ {

View File

@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Class StyleManager * Class StyleManager
* Manages styles to be applied to a cell * Manages styles to be applied to a cell
*
* @package Box\Spout\Writer\Common\Manager\Style
*/ */
class StyleManager implements StyleManagerInterface class StyleManager implements StyleManagerInterface
{ {
@ -57,6 +55,7 @@ class StyleManager implements StyleManagerInterface
public function applyExtraStylesIfNeeded($style, $dataRow) public function applyExtraStylesIfNeeded($style, $dataRow)
{ {
$updatedStyle = $this->applyWrapTextIfCellContainsNewLine($style, $dataRow); $updatedStyle = $this->applyWrapTextIfCellContainsNewLine($style, $dataRow);
return $updatedStyle; return $updatedStyle;
} }

View File

@ -6,8 +6,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Interface StyleHManagernterface * Interface StyleHManagernterface
*
* @package Box\Spout\Writer\Common\Manager\Style
*/ */
interface StyleManagerInterface interface StyleManagerInterface
{ {

View File

@ -2,15 +2,11 @@
namespace Box\Spout\Writer\Common\Manager\Style; namespace Box\Spout\Writer\Common\Manager\Style;
use Box\Spout\Writer\Common\Entity\Style\Color;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\XLSX\Helper\BorderHelper;
/** /**
* Class StyleMerger * Class StyleMerger
* Takes care of merging styles together * Takes care of merging styles together
*
* @package Box\Spout\Writer\Common\Manager\Style
*/ */
class StyleMerger class StyleMerger
{ {

View File

@ -7,8 +7,6 @@ use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Class StyleRegistry * Class StyleRegistry
* Registry for all used styles * Registry for all used styles
*
* @package Box\Spout\Writer\Common\Manager\Style
*/ */
class StyleRegistry class StyleRegistry
{ {
@ -72,6 +70,7 @@ class StyleRegistry
protected function getStyleFromSerializedStyle($serializedStyle) protected function getStyleFromSerializedStyle($serializedStyle)
{ {
$styleId = $this->serializedStyleToStyleIdMappingTable[$serializedStyle]; $styleId = $this->serializedStyleToStyleIdMappingTable[$serializedStyle];
return $this->styleIdToStyleMappingTable[$styleId]; return $this->styleIdToStyleMappingTable[$styleId];
} }

View File

@ -4,23 +4,21 @@ namespace Box\Spout\Writer\Common\Manager;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Manager\OptionsManagerInterface; use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface; use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
use Box\Spout\Writer\Common\Entity\Options; use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
use Box\Spout\Writer\Common\Manager\Style\StyleManagerInterface;
use Box\Spout\Writer\Exception\SheetNotFoundException; use Box\Spout\Writer\Exception\SheetNotFoundException;
use Box\Spout\Writer\Exception\WriterException; use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Creator\EntityFactory;
use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Class WorkbookManagerAbstract * Class WorkbookManagerAbstract
* Abstract workbook manager, providing the generic interfaces to work with workbook. * Abstract workbook manager, providing the generic interfaces to work with workbook.
*
* @package Box\Spout\Writer\Common\Manager
*/ */
abstract class WorkbookManagerAbstract implements WorkbookManagerInterface abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
{ {
@ -48,7 +46,6 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/** @var Worksheet The worksheet where data will be written to */ /** @var Worksheet The worksheet where data will be written to */
protected $currentWorksheet; protected $currentWorksheet;
/** /**
* @param Workbook $workbook * @param Workbook $workbook
* @param OptionsManagerInterface $optionsManager * @param OptionsManagerInterface $optionsManager
@ -65,8 +62,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
StyleManagerInterface $styleManager, StyleManagerInterface $styleManager,
FileSystemWithRootFolderHelperInterface $fileSystemHelper, FileSystemWithRootFolderHelperInterface $fileSystemHelper,
EntityFactory $entityFactory, EntityFactory $entityFactory,
ManagerFactoryInterface $managerFactory) ManagerFactoryInterface $managerFactory
{ ) {
$this->workbook = $workbook; $this->workbook = $workbook;
$this->optionManager = $optionsManager; $this->optionManager = $optionsManager;
$this->worksheetManager = $worksheetManager; $this->worksheetManager = $worksheetManager;
@ -99,8 +96,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* Creates a new sheet in the workbook and make it the current sheet. * Creates a new sheet in the workbook and make it the current sheet.
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @return Worksheet The created sheet
* @throws IOException If unable to open the sheet for writing * @throws IOException If unable to open the sheet for writing
* @return Worksheet The created sheet
*/ */
public function addNewSheetAndMakeItCurrent() public function addNewSheetAndMakeItCurrent()
{ {
@ -113,8 +110,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/** /**
* Creates a new sheet in the workbook. The current sheet remains unchanged. * Creates a new sheet in the workbook. The current sheet remains unchanged.
* *
* @return Worksheet The created sheet
* @throws \Box\Spout\Common\Exception\IOException If unable to open the sheet for writing * @throws \Box\Spout\Common\Exception\IOException If unable to open the sheet for writing
* @return Worksheet The created sheet
*/ */
private function addNewSheet() private function addNewSheet()
{ {
@ -158,8 +155,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The "external" sheet to set as current * @param Sheet $sheet The "external" sheet to set as current
* @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook * @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void
*/ */
public function setCurrentSheet(Sheet $sheet) public function setCurrentSheet(Sheet $sheet)
{ {
@ -208,9 +205,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param array $dataRow Array containing data to be written. Cannot be empty. * @param array $dataRow Array containing data to be written. Cannot be empty.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param Style $style Style to be applied to the row. * @param Style $style Style to be applied to the row.
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing * @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void
*/ */
public function addRowToCurrentWorksheet($dataRow, Style $style) public function addRowToCurrentWorksheet($dataRow, Style $style)
{ {
@ -238,6 +235,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
private function hasCurrentWorkseetReachedMaxRows() private function hasCurrentWorkseetReachedMaxRows()
{ {
$currentWorksheet = $this->getCurrentWorksheet(); $currentWorksheet = $this->getCurrentWorksheet();
return ($currentWorksheet->getLastWrittenRowIndex() >= $this->getMaxRowsPerWorksheet()); return ($currentWorksheet->getLastWrittenRowIndex() >= $this->getMaxRowsPerWorksheet());
} }
@ -248,8 +246,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param array $dataRow Array containing data to be written. Cannot be empty. * @param array $dataRow Array containing data to be written. Cannot be empty.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param Style $style Style to be applied to the row. * @param Style $style Style to be applied to the row.
* @return void
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void
*/ */
private function addRowWithStyleToWorksheet(Worksheet $worksheet, $dataRow, Style $style) private function addRowWithStyleToWorksheet(Worksheet $worksheet, $dataRow, Style $style)
{ {

View File

@ -4,17 +4,15 @@ namespace Box\Spout\Writer\Common\Manager;
use Box\Spout\Common\Exception\IOException; use Box\Spout\Common\Exception\IOException;
use Box\Spout\Writer\Common\Entity\Sheet; use Box\Spout\Writer\Common\Entity\Sheet;
use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Workbook; use Box\Spout\Writer\Common\Entity\Workbook;
use Box\Spout\Writer\Common\Entity\Worksheet; use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Exception\SheetNotFoundException; use Box\Spout\Writer\Exception\SheetNotFoundException;
use Box\Spout\Writer\Exception\WriterException; use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Entity\Style\Style;
/** /**
* Interface WorkbookManagerInterface * Interface WorkbookManagerInterface
* workbook manager interface, providing the generic interfaces to work with workbook. * workbook manager interface, providing the generic interfaces to work with workbook.
*
* @package Box\Spout\Writer\Common\Manager
*/ */
interface WorkbookManagerInterface interface WorkbookManagerInterface
{ {
@ -27,8 +25,8 @@ interface WorkbookManagerInterface
* Creates a new sheet in the workbook and make it the current sheet. * Creates a new sheet in the workbook and make it the current sheet.
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @return Worksheet The created sheet
* @throws IOException If unable to open the sheet for writing * @throws IOException If unable to open the sheet for writing
* @return Worksheet The created sheet
*/ */
public function addNewSheetAndMakeItCurrent(); public function addNewSheetAndMakeItCurrent();
@ -49,8 +47,8 @@ interface WorkbookManagerInterface
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The "external" sheet to set as current * @param Sheet $sheet The "external" sheet to set as current
* @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook * @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void
*/ */
public function setCurrentSheet(Sheet $sheet); public function setCurrentSheet(Sheet $sheet);
@ -62,9 +60,9 @@ interface WorkbookManagerInterface
* @param array $dataRow Array containing data to be written. Cannot be empty. * @param array $dataRow Array containing data to be written. Cannot be empty.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param Style $style Style to be applied to the row. * @param Style $style Style to be applied to the row.
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing * @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws WriterException If unable to write data * @throws WriterException If unable to write data
* @return void
*/ */
public function addRowToCurrentWorksheet($dataRow, Style $style); public function addRowToCurrentWorksheet($dataRow, Style $style);

View File

@ -2,14 +2,12 @@
namespace Box\Spout\Writer\Common\Manager; namespace Box\Spout\Writer\Common\Manager;
use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Entity\Style\Style; use Box\Spout\Writer\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Entity\Worksheet;
/** /**
* Interface WorksheetManagerInterface * Interface WorksheetManagerInterface
* Inteface for worksheet managers, providing the generic interfaces to work with worksheets. * Inteface for worksheet managers, providing the generic interfaces to work with worksheets.
*
* @package Box\Spout\Writer\Common\Manager
*/ */
interface WorksheetManagerInterface interface WorksheetManagerInterface
{ {
@ -20,9 +18,9 @@ interface WorksheetManagerInterface
* @param array $dataRow Array containing data to be written. Cannot be empty. * @param array $dataRow Array containing data to be written. Cannot be empty.
* Example $dataRow = ['data1', 1234, null, '', 'data5']; * Example $dataRow = ['data1', 1234, null, '', 'data5'];
* @param Style $rowStyle Style to be applied to the row. NULL means use default style. * @param Style $rowStyle Style to be applied to the row. NULL means use default style.
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the data cannot be written * @throws \Box\Spout\Common\Exception\IOException If the data cannot be written
* @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported * @throws \Box\Spout\Common\Exception\InvalidArgumentException If a cell value's type is not supported
* @return void
*/ */
public function addRow(Worksheet $worksheet, $dataRow, $rowStyle); public function addRow(Worksheet $worksheet, $dataRow, $rowStyle);
@ -30,8 +28,8 @@ interface WorksheetManagerInterface
* Prepares the worksheet to accept data * Prepares the worksheet to accept data
* *
* @param Worksheet $worksheet The worksheet to start * @param Worksheet $worksheet The worksheet to start
* @return void
* @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing * @throws \Box\Spout\Common\Exception\IOException If the sheet data file cannot be opened for writing
* @return void
*/ */
public function startSheet(Worksheet $worksheet); public function startSheet(Worksheet $worksheet);

View File

@ -2,8 +2,8 @@
namespace Box\Spout\Writer\Exception\Border; namespace Box\Spout\Writer\Exception\Border;
use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Entity\Style\BorderPart; use Box\Spout\Writer\Common\Entity\Style\BorderPart;
use Box\Spout\Writer\Exception\WriterException;
class InvalidNameException extends WriterException class InvalidNameException extends WriterException
{ {

View File

@ -2,8 +2,8 @@
namespace Box\Spout\Writer\Exception\Border; namespace Box\Spout\Writer\Exception\Border;
use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Entity\Style\BorderPart; use Box\Spout\Writer\Common\Entity\Style\BorderPart;
use Box\Spout\Writer\Exception\WriterException;
class InvalidStyleException extends WriterException class InvalidStyleException extends WriterException
{ {

View File

@ -2,8 +2,8 @@
namespace Box\Spout\Writer\Exception\Border; namespace Box\Spout\Writer\Exception\Border;
use Box\Spout\Writer\Exception\WriterException;
use Box\Spout\Writer\Common\Entity\Style\BorderPart; use Box\Spout\Writer\Common\Entity\Style\BorderPart;
use Box\Spout\Writer\Exception\WriterException;
class InvalidWidthException extends WriterException class InvalidWidthException extends WriterException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Writer\Exception;
* Class InvalidColorException * Class InvalidColorException
* *
* @api * @api
* @package Box\Spout\Writer\Exception
*/ */
class InvalidColorException extends WriterException class InvalidColorException extends WriterException
{ {

View File

@ -6,7 +6,6 @@ namespace Box\Spout\Writer\Exception;
* Class InvalidSheetNameException * Class InvalidSheetNameException
* *
* @api * @api
* @package Box\Spout\Writer\Exception
*/ */
class InvalidSheetNameException extends WriterException class InvalidSheetNameException extends WriterException
{ {

Some files were not shown because too many files have changed in this diff Show More