More PSR-2 work

This commit is contained in:
MarkBaker 2015-05-07 01:14:36 +01:00
parent 3c3154c4a3
commit 4f8c9bfc96
15 changed files with 1298 additions and 1340 deletions

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText implements PHPExcel_IComparable
{
/**
@ -40,7 +32,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*
* @var PHPExcel_RichText_ITextElement[]
*/
private $_richTextElements;
private $richTextElements;
/**
* Create a new PHPExcel_RichText instance
@ -51,10 +43,10 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function __construct(PHPExcel_Cell $pCell = null)
{
// Initialise variables
$this->_richTextElements = array();
$this->richTextElements = array();
// Rich-Text string attached to cell?
if ($pCell !== NULL) {
if ($pCell !== null) {
// Add cell text and style
if ($pCell->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
@ -76,7 +68,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/
public function addText(PHPExcel_RichText_ITextElement $pText = null)
{
$this->_richTextElements[] = $pText;
$this->richTextElements[] = $pText;
return $this;
}
@ -119,7 +111,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$returnValue = '';
// Loop through all PHPExcel_RichText_ITextElement
foreach ($this->_richTextElements as $text) {
foreach ($this->richTextElements as $text) {
$returnValue .= $text->getText();
}
@ -144,7 +136,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/
public function getRichTextElements()
{
return $this->_richTextElements;
return $this->richTextElements;
}
/**
@ -157,7 +149,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function setRichTextElements($pElements = null)
{
if (is_array($pElements)) {
$this->_richTextElements = $pElements;
$this->richTextElements = $pElements;
} else {
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
}
@ -172,13 +164,13 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function getHashCode()
{
$hashElements = '';
foreach ($this->_richTextElements as $element) {
foreach ($this->richTextElements as $element) {
$hashElements .= $element->getHashCode();
}
return md5(
$hashElements
. __CLASS__
$hashElements .
__CLASS__
);
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_ITextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_ITextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_RichText_ITextElement
{
/**

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_Run
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_Run
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
@ -38,7 +30,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @var PHPExcel_Style_Font
*/
private $_font;
private $font;
/**
* Create a new PHPExcel_RichText_Run instance
@ -49,7 +41,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
{
// Initialise variables
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
$this->font = new PHPExcel_Style_Font();
}
/**
@ -57,8 +49,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
return $this->_font;
public function getFont()
{
return $this->font;
}
/**
@ -68,8 +61,9 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
* @throws PHPExcel_Exception
* @return PHPExcel_RichText_ITextElement
*/
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
public function setFont(PHPExcel_Style_Font $pFont = null)
{
$this->font = $pFont;
return $this;
}
@ -78,18 +72,20 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->getText()
. $this->_font->getHashCode()
. __CLASS__
$this->getText() .
$this->_font->getHashCode() .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_RichText_TextElement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,15 +23,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_RichText_TextElement
*
* @category PHPExcel
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
/**
@ -38,7 +30,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @var string
*/
private $_text;
private $text;
/**
* Create a new PHPExcel_RichText_TextElement instance
@ -48,7 +40,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
public function __construct($pText = '')
{
// Initialise variables
$this->_text = $pText;
$this->text = $pText;
}
/**
@ -56,8 +48,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return string Text
*/
public function getText() {
return $this->_text;
public function getText()
{
return $this->text;
}
/**
@ -66,8 +59,9 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
public function setText($pText = '') {
$this->_text = $pText;
public function setText($pText = '')
{
$this->text = $pText;
return $this;
}
@ -76,7 +70,8 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return PHPExcel_Style_Font
*/
public function getFont() {
public function getFont()
{
return null;
}
@ -85,17 +80,19 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
return md5(
$this->_text
. __CLASS__
$this->_text .
__CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View File

@ -1,6 +1,16 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Settings
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
class PHPExcel_Settings
{
/** constants */
@ -51,11 +50,11 @@ class PHPExcel_Settings
const PDF_RENDERER_MPDF = 'mPDF';
private static $_chartRenderers = array(
private static $chartRenderers = array(
self::CHART_RENDERER_JPGRAPH,
);
private static $_pdfRenderers = array(
private static $pdfRenderers = array(
self::PDF_RENDERER_TCPDF,
self::PDF_RENDERER_DOMPDF,
self::PDF_RENDERER_MPDF,
@ -69,7 +68,7 @@ class PHPExcel_Settings
*
* @var string
*/
private static $_zipClass = self::ZIPARCHIVE;
private static $zipClass = self::ZIPARCHIVE;
/**
@ -79,14 +78,14 @@ class PHPExcel_Settings
*
* @var string
*/
private static $_chartRendererName = NULL;
private static $chartRendererName;
/**
* Directory Path to the external Library used for rendering charts
*
* @var string
*/
private static $_chartRendererPath = NULL;
private static $chartRendererPath;
/**
@ -96,21 +95,21 @@ class PHPExcel_Settings
*
* @var string
*/
private static $_pdfRendererName = NULL;
private static $pdfRendererName;
/**
* Directory Path to the external Library used for rendering PDF files
*
* @var string
*/
private static $_pdfRendererPath = NULL;
private static $pdfRendererPath;
/**
* Default options for libxml loader
*
* @var int
*/
private static $_libXmlLoaderOptions = null;
private static $libXmlLoaderOptions = null;
/**
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
@ -123,11 +122,11 @@ class PHPExcel_Settings
{
if (($zipClass === self::PCLZIP) ||
($zipClass === self::ZIPARCHIVE)) {
self::$_zipClass = $zipClass;
return TRUE;
self::$zipClass = $zipClass;
return true;
}
return false;
}
return FALSE;
} // function setZipClass()
/**
@ -140,8 +139,8 @@ class PHPExcel_Settings
*/
public static function getZipClass()
{
return self::$_zipClass;
} // function getZipClass()
return self::$zipClass;
}
/**
@ -152,7 +151,7 @@ class PHPExcel_Settings
public static function getCacheStorageMethod()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
} // function getCacheStorageMethod()
}
/**
@ -163,7 +162,7 @@ class PHPExcel_Settings
public static function getCacheStorageClass()
{
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
} // function getCacheStorageClass()
}
/**
@ -173,13 +172,10 @@ class PHPExcel_Settings
* @param array $arguments Optional configuration arguments for the cacheing method
* @return boolean Success or failure
*/
public static function setCacheStorageMethod(
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
$arguments = array()
)
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array())
{
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
} // function setCacheStorageMethod()
}
/**
@ -188,10 +184,10 @@ class PHPExcel_Settings
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
* @return boolean Success or failure
*/
public static function setLocale($locale='en_us')
public static function setLocale($locale = 'en_us')
{
return PHPExcel_Calculation::getInstance()->setLocale($locale);
} // function setLocale()
}
/**
@ -205,10 +201,11 @@ class PHPExcel_Settings
*/
public static function setChartRenderer($libraryName, $libraryBaseDir)
{
if (!self::setChartRendererName($libraryName))
return FALSE;
if (!self::setChartRendererName($libraryName)) {
return false;
}
return self::setChartRendererPath($libraryBaseDir);
} // function setChartRenderer()
}
/**
@ -221,14 +218,13 @@ class PHPExcel_Settings
*/
public static function setChartRendererName($libraryName)
{
if (!in_array($libraryName,self::$_chartRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$chartRenderers)) {
return false;
}
self::$chartRendererName = $libraryName;
self::$_chartRendererName = $libraryName;
return TRUE;
} // function setChartRendererName()
return true;
}
/**
@ -240,12 +236,12 @@ class PHPExcel_Settings
public static function setChartRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_chartRendererPath = $libraryBaseDir;
self::$chartRendererPath = $libraryBaseDir;
return TRUE;
} // function setChartRendererPath()
return true;
}
/**
@ -257,8 +253,8 @@ class PHPExcel_Settings
*/
public static function getChartRendererName()
{
return self::$_chartRendererName;
} // function getChartRendererName()
return self::$chartRendererName;
}
/**
@ -269,8 +265,8 @@ class PHPExcel_Settings
*/
public static function getChartRendererPath()
{
return self::$_chartRendererPath;
} // function getChartRendererPath()
return self::$chartRendererPath;
}
/**
@ -286,10 +282,11 @@ class PHPExcel_Settings
*/
public static function setPdfRenderer($libraryName, $libraryBaseDir)
{
if (!self::setPdfRendererName($libraryName))
return FALSE;
if (!self::setPdfRendererName($libraryName)) {
return false;
}
return self::setPdfRendererPath($libraryBaseDir);
} // function setPdfRenderer()
}
/**
@ -304,14 +301,13 @@ class PHPExcel_Settings
*/
public static function setPdfRendererName($libraryName)
{
if (!in_array($libraryName,self::$_pdfRenderers)) {
return FALSE;
if (!in_array($libraryName, self::$pdfRenderers)) {
return false;
}
self::$_pdfRendererName = $libraryName;
return TRUE;
} // function setPdfRendererName()
return true;
}
/**
@ -323,12 +319,12 @@ class PHPExcel_Settings
public static function setPdfRendererPath($libraryBaseDir)
{
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
return FALSE;
return false;
}
self::$_pdfRendererPath = $libraryBaseDir;
self::$pdfRendererPath = $libraryBaseDir;
return TRUE;
} // function setPdfRendererPath()
return true;
}
/**
@ -342,8 +338,8 @@ class PHPExcel_Settings
*/
public static function getPdfRendererName()
{
return self::$_pdfRendererName;
} // function getPdfRendererName()
return self::$pdfRendererName;
}
/**
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
@ -353,8 +349,8 @@ class PHPExcel_Settings
*/
public static function getPdfRendererPath()
{
return self::$_pdfRendererPath;
} // function getPdfRendererPath()
return self::$pdfRendererPath;
}
/**
* Set default options for libxml loader
@ -370,7 +366,7 @@ class PHPExcel_Settings
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions
}
/**
* Get default options for libxml loader.
@ -384,8 +380,8 @@ class PHPExcel_Settings
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
}
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
@libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_CellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -22,18 +23,7 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.8.0, 2014-03-02
*/
/**
* PHPExcel_Worksheet_CellIterator
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_Worksheet_CellIterator
{
@ -42,27 +32,28 @@ abstract class PHPExcel_Worksheet_CellIterator
*
* @var PHPExcel_Worksheet
*/
protected $_subject;
protected $subject;
/**
* Current iterator position
*
* @var mixed
*/
protected $_position = null;
protected $position = null;
/**
* Iterate only existing cells
*
* @var boolean
*/
protected $_onlyExistingCells = false;
protected $onlyExistingCells = false;
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
public function __destruct()
{
unset($this->subject);
}
/**
@ -70,8 +61,9 @@ abstract class PHPExcel_Worksheet_CellIterator
*
* @return boolean
*/
public function getIterateOnlyExistingCells() {
return $this->_onlyExistingCells;
public function getIterateOnlyExistingCells()
{
return $this->onlyExistingCells;
}
/**
@ -87,8 +79,9 @@ abstract class PHPExcel_Worksheet_CellIterator
* @param boolean $value
* @throws PHPExcel_Exception
*/
public function setIterateOnlyExistingCells($value = true) {
$this->_onlyExistingCells = (boolean) $value;
public function setIterateOnlyExistingCells($value = true)
{
$this->onlyExistingCells = (boolean) $value;
$this->adjustForExistingOnlyRange();
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_Column
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_Column
*
* Represents a column in PHPExcel_Worksheet, used by PHPExcel_Worksheet_ColumnIterator
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Column
{
/**
@ -42,14 +32,14 @@ class PHPExcel_Worksheet_Column
*
* @var PHPExcel_Worksheet
*/
private $_parent;
private $parent;
/**
* Column index
*
* @var string
*/
private $_columnIndex;
private $columnIndex;
/**
* Create a new column
@ -57,17 +47,19 @@ class PHPExcel_Worksheet_Column
* @param PHPExcel_Worksheet $parent
* @param string $columnIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A') {
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A')
{
// Set parent and column index
$this->_parent = $parent;
$this->_columnIndex = $columnIndex;
$this->parent = $parent;
$this->columnIndex = $columnIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
public function __destruct()
{
unset($this->parent);
}
/**
@ -75,8 +67,9 @@ class PHPExcel_Worksheet_Column
*
* @return int
*/
public function getColumnIndex() {
return $this->_columnIndex;
public function getColumnIndex()
{
return $this->columnIndex;
}
/**
@ -86,7 +79,8 @@ class PHPExcel_Worksheet_Column
* @param integer $endRow Optionally, the row number at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startRow = 1, $endRow = null) {
return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow);
public function getCellIterator($startRow = 1, $endRow = null)
{
return new PHPExcel_Worksheet_ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnCellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
*
* @var string
*/
protected $_columnIndex;
protected $columnIndex;
/**
* Start position
*
* @var int
*/
protected $_startRow = 1;
protected $startRow = 1;
/**
* End position
*
* @var int
*/
protected $_endRow = 1;
protected $endRow = 1;
/**
* Create a new row iterator
@ -66,10 +56,11 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex, $startRow = 1, $endRow = null) {
public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex = 'A', $startRow = 1, $endRow = null)
{
// Set subject
$this->_subject = $subject;
$this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->subject = $subject;
$this->columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
@ -77,8 +68,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
public function __destruct()
{
unset($this->subject);
}
/**
@ -88,8 +80,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
public function resetStart($startRow = 1)
{
$this->startRow = $startRow;
$this->adjustForExistingOnlyRange();
$this->seek($startRow);
@ -103,8 +96,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
public function resetEnd($endRow = null)
{
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
$this->adjustForExistingOnlyRange();
return $this;
@ -117,13 +111,14 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function seek($row = 1) {
if (($row < $this->_startRow) || ($row > $this->_endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) {
public function seek($row = 1)
{
if (($row < $this->startRow) || ($row > $this->endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})");
} elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($this->columnIndex, $row))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $row;
$this->position = $row;
return $this;
}
@ -131,8 +126,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
/**
* Rewind the iterator to the starting row
*/
public function rewind() {
$this->_position = $this->_startRow;
public function rewind()
{
$this->position = $this->startRow;
}
/**
@ -140,8 +136,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
*
* @return PHPExcel_Worksheet_Row
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position);
public function current()
{
return $this->subject->getCellByColumnAndRow($this->columnIndex, $this->position);
}
/**
@ -149,34 +146,37 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
*
* @return int
*/
public function key() {
return $this->_position;
public function key()
{
return $this->position;
}
/**
* Set the iterator to its next value
*/
public function next() {
public function next()
{
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position <= $this->_endRow));
++$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->position <= $this->endRow));
}
/**
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
public function prev()
{
if ($this->position <= $this->startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position >= $this->_startRow));
--$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->position)) &&
($this->position >= $this->startRow));
}
/**
@ -184,8 +184,9 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endRow;
public function valid()
{
return $this->position <= $this->endRow;
}
/**
@ -193,23 +194,23 @@ class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellItera
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) &&
($this->_startRow <= $this->_endRow)) {
++$this->_startRow;
protected function adjustForExistingOnlyRange()
{
if ($this->onlyExistingCells) {
while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
($this->startRow <= $this->endRow)) {
++$this->startRow;
}
if ($this->_startRow > $this->_endRow) {
if ($this->startRow > $this->endRow) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) &&
($this->_endRow >= $this->_startRow)) {
--$this->_endRow;
while ((!$this->subject->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
($this->endRow >= $this->startRow)) {
--$this->endRow;
}
if ($this->_endRow < $this->_startRow) {
if ($this->endRow < $this->startRow) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnDimension
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnDimension
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnDimension
{
/**
@ -105,7 +97,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return string
*/
public function getColumnIndex() {
public function getColumnIndex()
{
return $this->_columnIndex;
}
@ -115,7 +108,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param string $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setColumnIndex($pValue) {
public function setColumnIndex($pValue)
{
$this->_columnIndex = $pValue;
return $this;
}
@ -125,7 +119,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return double
*/
public function getWidth() {
public function getWidth()
{
return $this->_width;
}
@ -135,7 +130,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param double $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setWidth($pValue = -1) {
public function setWidth($pValue = -1)
{
$this->_width = $pValue;
return $this;
}
@ -145,7 +141,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getAutoSize() {
public function getAutoSize()
{
return $this->_autoSize;
}
@ -155,7 +152,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setAutoSize($pValue = false) {
public function setAutoSize($pValue = false)
{
$this->_autoSize = $pValue;
return $this;
}
@ -165,7 +163,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getVisible() {
public function getVisible()
{
return $this->_visible;
}
@ -175,7 +174,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setVisible($pValue = true) {
public function setVisible($pValue = true)
{
$this->_visible = $pValue;
return $this;
}
@ -185,7 +185,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return int
*/
public function getOutlineLevel() {
public function getOutlineLevel()
{
return $this->_outlineLevel;
}
@ -198,7 +199,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setOutlineLevel($pValue) {
public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
@ -212,7 +214,8 @@ class PHPExcel_Worksheet_ColumnDimension
*
* @return bool
*/
public function getCollapsed() {
public function getCollapsed()
{
return $this->_collapsed;
}
@ -222,7 +225,8 @@ class PHPExcel_Worksheet_ColumnDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function setCollapsed($pValue = true) {
public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue;
return $this;
}
@ -252,7 +256,8 @@ class PHPExcel_Worksheet_ColumnDimension
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_ColumnIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnIterator implements Iterator
{
/**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @var PHPExcel_Worksheet
*/
private $_subject;
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
private $position = 0;
/**
* Start position
*
* @var int
*/
private $_startColumn = 0;
private $startColumn = 0;
/**
@ -64,7 +54,7 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @var int
*/
private $_endColumn = 0;
private $endColumn = 0;
/**
@ -74,9 +64,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) {
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null)
{
// Set subject
$this->_subject = $subject;
$this->subject = $subject;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
@ -84,8 +75,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
public function __destruct()
{
unset($this->subject);
}
/**
@ -94,9 +86,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetStart($startColumn = 'A') {
public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->startColumn = $startColumnIndex;
$this->seek($startColumn);
return $this;
@ -108,9 +101,10 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
public function resetEnd($endColumn = null)
{
$endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
return $this;
}
@ -122,12 +116,13 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
if (($column < $this->startColumn) || ($column > $this->endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})");
}
$this->_position = $column;
$this->position = $column;
return $this;
}
@ -135,8 +130,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
public function rewind()
{
$this->position = $this->startColumn;
}
/**
@ -144,8 +140,9 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @return PHPExcel_Worksheet_Column
*/
public function current() {
return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position));
public function current()
{
return new PHPExcel_Worksheet_Column($this->subject, PHPExcel_Cell::stringFromColumnIndex($this->position));
}
/**
@ -153,15 +150,17 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
public function key()
{
return PHPExcel_Cell::stringFromColumnIndex($this->position);
}
/**
* Set the iterator to its next value
*/
public function next() {
++$this->_position;
public function next()
{
++$this->position;
}
/**
@ -169,16 +168,17 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
public function prev()
{
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
);
}
--$this->_position;
--$this->position;
}
/**
@ -186,7 +186,8 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
public function valid()
{
return $this->position <= $this->endColumn;
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_Row
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_Row
*
* Represents a row in PHPExcel_Worksheet, used by PHPExcel_Worksheet_RowIterator
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Row
{
/**
@ -42,14 +32,14 @@ class PHPExcel_Worksheet_Row
*
* @var PHPExcel_Worksheet
*/
private $_parent;
private $parent;
/**
* Row index
*
* @var int
*/
private $_rowIndex = 0;
private $rowIndex = 0;
/**
* Create a new row
@ -57,17 +47,19 @@ class PHPExcel_Worksheet_Row
* @param PHPExcel_Worksheet $parent
* @param int $rowIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1) {
public function __construct(PHPExcel_Worksheet $parent = null, $rowIndex = 1)
{
// Set parent and row index
$this->_parent = $parent;
$this->_rowIndex = $rowIndex;
$this->parent = $parent;
$this->rowIndex = $rowIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
public function __destruct()
{
unset($this->parent);
}
/**
@ -75,8 +67,9 @@ class PHPExcel_Worksheet_Row
*
* @return int
*/
public function getRowIndex() {
return $this->_rowIndex;
public function getRowIndex()
{
return $this->rowIndex;
}
/**
@ -86,7 +79,8 @@ class PHPExcel_Worksheet_Row
* @param string $endColumn Optionally, the column address at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startColumn = 'A', $endColumn = null) {
return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn);
public function getCellIterator($startColumn = 'A', $endColumn = null)
{
return new PHPExcel_Worksheet_RowCellIterator($this->parent, $this->rowIndex, $startColumn, $endColumn);
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowCellIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @var int
*/
protected $_rowIndex;
protected $rowIndex;
/**
* Start position
*
* @var int
*/
protected $_startColumn = 0;
protected $startColumn = 0;
/**
* End position
*
* @var int
*/
protected $_endColumn = 0;
protected $endColumn = 0;
/**
* Create a new column iterator
@ -66,10 +56,11 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) {
public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null)
{
// Set subject and row index
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
$this->subject = $subject;
$this->rowIndex = $rowIndex;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
@ -77,8 +68,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
public function __destruct()
{
unset($this->subject);
}
/**
@ -88,11 +80,12 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startColumn = 'A') {
public function resetStart($startColumn = 'A')
{
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->startColumn = $startColumnIndex;
$this->adjustForExistingOnlyRange();
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn));
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->startColumn));
return $this;
}
@ -104,9 +97,10 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
public function resetEnd($endColumn = null)
{
$endColumn = ($endColumn) ? $endColumn : $this->subject->getHighestColumn();
$this->endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
$this->adjustForExistingOnlyRange();
return $this;
@ -119,14 +113,15 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
public function seek($column = 'A')
{
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($column, $this->_rowIndex))) {
if (($column < $this->startColumn) || ($column > $this->endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->startColumn} - {$this->endColumn})");
} elseif ($this->onlyExistingCells && !($this->subject->cellExistsByColumnAndRow($column, $this->rowIndex))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $column;
$this->position = $column;
return $this;
}
@ -134,8 +129,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
public function rewind()
{
$this->position = $this->startColumn;
}
/**
@ -143,8 +139,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @return PHPExcel_Cell
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
public function current()
{
return $this->subject->getCellByColumnAndRow($this->position, $this->rowIndex);
}
/**
@ -152,19 +149,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
public function key()
{
return PHPExcel_Cell::stringFromColumnIndex($this->position);
}
/**
* Set the iterator to its next value
*/
public function next() {
public function next()
{
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position <= $this->_endColumn));
++$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->position <= $this->endColumn));
}
/**
@ -172,20 +171,21 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
public function prev()
{
if ($this->position <= $this->startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->endColumn) . ")"
);
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position >= $this->_startColumn));
--$this->position;
} while (($this->onlyExistingCells) &&
(!$this->subject->cellExistsByColumnAndRow($this->position, $this->rowIndex)) &&
($this->position >= $this->startColumn));
}
/**
@ -193,8 +193,9 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
public function valid()
{
return $this->position <= $this->endColumn;
}
/**
@ -202,23 +203,23 @@ class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) &&
($this->_startColumn <= $this->_endColumn)) {
++$this->_startColumn;
protected function adjustForExistingOnlyRange()
{
if ($this->onlyExistingCells) {
while ((!$this->subject->cellExistsByColumnAndRow($this->startColumn, $this->rowIndex)) &&
($this->startColumn <= $this->endColumn)) {
++$this->startColumn;
}
if ($this->_startColumn > $this->_endColumn) {
if ($this->startColumn > $this->endColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) &&
($this->_endColumn >= $this->_startColumn)) {
--$this->_endColumn;
while ((!$this->subject->cellExistsByColumnAndRow($this->endColumn, $this->rowIndex)) &&
($this->endColumn >= $this->startColumn)) {
--$this->endColumn;
}
if ($this->_endColumn < $this->_startColumn) {
if ($this->endColumn < $this->startColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowDimension
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowDimension
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowDimension
{
/**
@ -105,7 +97,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return int
*/
public function getRowIndex() {
public function getRowIndex()
{
return $this->_rowIndex;
}
@ -115,7 +108,8 @@ class PHPExcel_Worksheet_RowDimension
* @param int $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setRowIndex($pValue) {
public function setRowIndex($pValue)
{
$this->_rowIndex = $pValue;
return $this;
}
@ -125,7 +119,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return double
*/
public function getRowHeight() {
public function getRowHeight()
{
return $this->_rowHeight;
}
@ -135,7 +130,8 @@ class PHPExcel_Worksheet_RowDimension
* @param double $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setRowHeight($pValue = -1) {
public function setRowHeight($pValue = -1)
{
$this->_rowHeight = $pValue;
return $this;
}
@ -145,7 +141,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return bool
*/
public function getZeroHeight() {
public function getZeroHeight()
{
return $this->_zeroHeight;
}
@ -155,7 +152,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setZeroHeight($pValue = false) {
public function setZeroHeight($pValue = false)
{
$this->_zeroHeight = $pValue;
return $this;
}
@ -165,7 +163,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return bool
*/
public function getVisible() {
public function getVisible()
{
return $this->_visible;
}
@ -175,7 +174,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setVisible($pValue = true) {
public function setVisible($pValue = true)
{
$this->_visible = $pValue;
return $this;
}
@ -185,7 +185,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return int
*/
public function getOutlineLevel() {
public function getOutlineLevel()
{
return $this->_outlineLevel;
}
@ -198,7 +199,8 @@ class PHPExcel_Worksheet_RowDimension
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet_RowDimension
*/
public function setOutlineLevel($pValue) {
public function setOutlineLevel($pValue)
{
if ($pValue < 0 || $pValue > 7) {
throw new PHPExcel_Exception("Outline level must range between 0 and 7.");
}
@ -212,7 +214,8 @@ class PHPExcel_Worksheet_RowDimension
*
* @return bool
*/
public function getCollapsed() {
public function getCollapsed()
{
return $this->_collapsed;
}
@ -222,7 +225,8 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setCollapsed($pValue = true) {
public function setCollapsed($pValue = true)
{
$this->_collapsed = $pValue;
return $this;
}
@ -252,7 +256,8 @@ class PHPExcel_Worksheet_RowDimension
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Worksheet_RowIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowIterator
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowIterator implements Iterator
{
/**
@ -42,21 +32,21 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
*
* @var PHPExcel_Worksheet
*/
private $_subject;
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 1;
private $position = 1;
/**
* Start position
*
* @var int
*/
private $_startRow = 1;
private $startRow = 1;
/**
@ -64,7 +54,7 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
*
* @var int
*/
private $_endRow = 1;
private $endRow = 1;
/**
@ -74,9 +64,10 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) {
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null)
{
// Set subject
$this->_subject = $subject;
$this->subject = $subject;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
@ -84,8 +75,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
public function __destruct()
{
unset($this->subject);
}
/**
@ -94,8 +86,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
public function resetStart($startRow = 1)
{
$this->startRow = $startRow;
$this->seek($startRow);
return $this;
@ -107,8 +100,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
public function resetEnd($endRow = null)
{
$this->endRow = ($endRow) ? $endRow : $this->subject->getHighestRow();
return $this;
}
@ -120,11 +114,12 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @return PHPExcel_Worksheet_RowIterator
* @throws PHPExcel_Exception
*/
public function seek($row = 1) {
if (($row < $this->_startRow) || ($row > $this->_endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
public function seek($row = 1)
{
if (($row < $this->startRow) || ($row > $this->endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->startRow} - {$this->endRow})");
}
$this->_position = $row;
$this->position = $row;
return $this;
}
@ -132,8 +127,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
/**
* Rewind the iterator to the starting row
*/
public function rewind() {
$this->_position = $this->_startRow;
public function rewind()
{
$this->position = $this->startRow;
}
/**
@ -141,8 +137,9 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
*
* @return PHPExcel_Worksheet_Row
*/
public function current() {
return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
public function current()
{
return new PHPExcel_Worksheet_Row($this->subject, $this->position);
}
/**
@ -150,26 +147,29 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
*
* @return int
*/
public function key() {
return $this->_position;
public function key()
{
return $this->position;
}
/**
* Set the iterator to its next value
*/
public function next() {
++$this->_position;
public function next()
{
++$this->position;
}
/**
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
public function prev()
{
if ($this->position <= $this->startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}
--$this->_position;
--$this->position;
}
/**
@ -177,7 +177,8 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endRow;
public function valid()
{
return $this->position <= $this->endRow;
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_WorksheetIterator
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_WorksheetIterator
*
* Used to iterate worksheets in PHPExcel
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_WorksheetIterator implements Iterator
{
/**
@ -42,14 +32,14 @@ class PHPExcel_WorksheetIterator implements Iterator
*
* @var PHPExcel
*/
private $_subject;
private $subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
private $position = 0;
/**
* Create a new worksheet iterator
@ -59,7 +49,7 @@ class PHPExcel_WorksheetIterator implements Iterator
public function __construct(PHPExcel $subject = null)
{
// Set subject
$this->_subject = $subject;
$this->subject = $subject;
}
/**
@ -67,7 +57,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function __destruct()
{
unset($this->_subject);
unset($this->subject);
}
/**
@ -75,7 +65,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function rewind()
{
$this->_position = 0;
$this->position = 0;
}
/**
@ -85,7 +75,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function current()
{
return $this->_subject->getSheet($this->_position);
return $this->subject->getSheet($this->position);
}
/**
@ -95,7 +85,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function key()
{
return $this->_position;
return $this->position;
}
/**
@ -103,7 +93,7 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function next()
{
++$this->_position;
++$this->position;
}
/**
@ -113,6 +103,6 @@ class PHPExcel_WorksheetIterator implements Iterator
*/
public function valid()
{
return $this->_position < $this->_subject->getSheetCount();
return $this->position < $this->subject->getSheetCount();
}
}