PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-16 19:00:31 +02:00
parent 1bf5ea414b
commit f827a25af2
17 changed files with 5212 additions and 5642 deletions

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ class PHPExcel_Shared_PasswordHasher
* @param string $pPassword Password to hash
* @return string Hashed password
*/
public static function hashPassword($pPassword = '') {
public static function hashPassword($pPassword = '')
{
$password = 0x0000;
$charPos = 1; // char position

View File

@ -93,10 +93,11 @@ class PHPExcel_Shared_String
/**
* Build control characters array
*/
private static function _buildControlCharacters() {
private static function _buildControlCharacters()
{
for ($i = 0; $i <= 31; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
$replace = chr($i);
self::$_controlCharacters[$find] = $replace;
}
@ -316,10 +317,7 @@ class PHPExcel_Shared_String
}
// CUSTOM: IBM AIX iconv() does not work
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
{
if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
self::$_isIconvEnabled = false;
return false;
}
@ -329,7 +327,8 @@ class PHPExcel_Shared_String
return true;
}
public static function buildCharacterSets() {
public static function buildCharacterSets()
{
if (empty(self::$_controlCharacters)) {
self::_buildControlCharacters();
}
@ -352,8 +351,9 @@ class PHPExcel_Shared_String
* @param string $value Value to unescape
* @return string
*/
public static function ControlCharacterOOXML2PHP($value = '') {
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
public static function ControlCharacterOOXML2PHP($value = '')
{
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value);
}
/**
@ -370,8 +370,9 @@ class PHPExcel_Shared_String
* @param string $value Value to escape
* @return string
*/
public static function ControlCharacterPHP2OOXML($value = '') {
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
public static function ControlCharacterPHP2OOXML($value = '')
{
return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value);
}
/**
@ -402,7 +403,8 @@ class PHPExcel_Shared_String
* @param string $value
* @return boolean
*/
public static function IsUTF8($value = '') {
public static function IsUTF8($value = '')
{
return $value === '' || preg_match('/^./su', $value) === 1;
}
@ -413,7 +415,8 @@ class PHPExcel_Shared_String
* @param mixed $value
* @return string
*/
public static function FormatNumber($value) {
public static function FormatNumber($value)
{
if (is_float($value)) {
return str_replace(',', '.', $value);
}
@ -524,16 +527,27 @@ class PHPExcel_Shared_String
* @author vadik56
*/
public static function utf16_decode($str, $bom_be = TRUE) {
if ( strlen($str) < 2 ) return $str;
if (strlen($str) < 2) {
return $str;
}
$c0 = ord($str{0});
$c1 = ord($str{1});
if ( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
elseif ( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
if ($c0 == 0xfe && $c1 == 0xff) {
$str = substr($str,2);
} elseif ($c0 == 0xff && $c1 == 0xfe) {
$str = substr($str,2);
$bom_be = false;
}
$len = strlen($str);
$newstr = '';
for($i=0;$i<$len;$i+=2) {
if ( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
if ($bom_be) {
$val = ord($str{$i}) << 4;
$val += ord($str{$i+1});
} else {
$val = ord($str{$i+1}) << 4;
$val += ord($str{$i});
}
$newstr .= ($val == 0x228) ? "\n" : chr($val);
}
return $newstr;
@ -634,7 +648,7 @@ class PHPExcel_Shared_String
{
# Split at all position not after the start: ^
# and not before the end: $
return preg_split('/(?<!^)(?!$)/u', $string );
return preg_split('/(?<!^)(?!$)/u', $string);
}
/**
@ -667,7 +681,8 @@ class PHPExcel_Shared_String
* @param string &$operand string value to test
* @return boolean
*/
public static function convertToNumberIfFraction(&$operand) {
public static function convertToNumberIfFraction(&$operand)
{
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
$sign = ($match[1] == '-') ? '-' : '+';
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
@ -802,8 +817,9 @@ class PHPExcel_Shared_String
*/
public static function testStringAsNumeric($value)
{
if (is_numeric($value))
if (is_numeric($value)) {
return $value;
}
$v = floatval($value);
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
}

View File

@ -50,7 +50,8 @@ class PHPExcel_Shared_TimeZone
* @param string $timezone Time zone (e.g. 'Europe/London')
* @return boolean Success or failure
*/
public static function _validateTimeZone($timezone) {
public static function _validateTimeZone($timezone)
{
if (in_array($timezone, DateTimeZone::listIdentifiers())) {
return true;
}
@ -63,7 +64,8 @@ class PHPExcel_Shared_TimeZone
* @param string $timezone Time zone (e.g. 'Europe/London')
* @return boolean Success or failure
*/
public static function setTimeZone($timezone) {
public static function setTimeZone($timezone)
{
if (self::_validateTimezone($timezone)) {
self::$_timezone = $timezone;
return true;
@ -77,7 +79,8 @@ class PHPExcel_Shared_TimeZone
*
* @return string Timezone (e.g. 'Europe/London')
*/
public static function getTimeZone() {
public static function getTimeZone()
{
return self::$_timezone;
} // function getTimezone()
@ -89,7 +92,8 @@ class PHPExcel_Shared_TimeZone
* @param integer $timestamp PHP date/time value for finding the current transition
* @return array The current transition details
*/
private static function _getTimezoneTransitions($objTimezone, $timestamp) {
private static function _getTimezoneTransitions($objTimezone, $timestamp)
{
$allTransitions = $objTimezone->getTransitions();
$transitions = array();
foreach ($allTransitions as $key => $transition) {
@ -114,7 +118,8 @@ class PHPExcel_Shared_TimeZone
* @return integer Number of seconds for timezone adjustment
* @throws PHPExcel_Exception
*/
public static function getTimeZoneAdjustment($timezone, $timestamp) {
public static function getTimeZoneAdjustment($timezone, $timestamp)
{
if ($timezone !== null) {
if (!self::_validateTimezone($timezone)) {
throw new PHPExcel_Exception("Invalid timezone " . $timezone);

View File

@ -33,7 +33,6 @@ if (!defined('DEBUGMODE_ENABLED')) {
define('DEBUGMODE_ENABLED', false);
}
/**
* PHPExcel_Shared_XMLWriter
*
@ -41,7 +40,8 @@ if (!defined('DEBUGMODE_ENABLED')) {
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_XMLWriter extends XMLWriter {
class PHPExcel_Shared_XMLWriter extends XMLWriter
{
/** Temporary storage method */
const STORAGE_MEMORY = 1;
const STORAGE_DISK = 2;
@ -59,14 +59,15 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
* @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder
*/
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = NULL) {
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null) {
// Open temporary storage
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
$this->openMemory();
} else {
// Create temporary filename
if ($pTemporaryStorageFolder === NULL)
if ($pTemporaryStorageFolder === null) {
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
}
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
// Open storage
@ -85,7 +86,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
/**
* Destructor
*/
public function __destruct() {
public function __destruct()
{
// Unlink temporary files
if ($this->_tempFileName != '') {
@unlink($this->_tempFileName);
@ -97,7 +99,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
*
* @return $data
*/
public function getData() {
public function getData()
{
if ($this->_tempFileName == '') {
return $this->outputMemory(true);
} else {

View File

@ -92,10 +92,7 @@ class PHPExcel_Shared_ZipArchive
fwrite($handle, $contents);
fclose($handle);
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"],
PCLZIP_OPT_REMOVE_PATH, $this->_tempDir,
PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]
);
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->_tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]);
if ($res == 0) {
throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true));
}

View File

@ -25,11 +25,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Shared_ZipStreamWrapper {
class PHPExcel_Shared_ZipStreamWrapper
{
/**
* Internal ZipAcrhive
*
* @var ZipAcrhive
* @var ZipArchive
*/
private $_archive;

View File

@ -25,7 +25,6 @@
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Best_Fit
*
@ -75,7 +74,7 @@ class PHPExcel_Best_Fit
*
* @var boolean
**/
protected $_adjustToZero = False;
protected $_adjustToZero = false;
/**
* Y-value series of best-fit values
@ -113,205 +112,207 @@ class PHPExcel_Best_Fit
protected $_Yoffset = 0;
public function getError() {
public function getError()
{
return $this->_error;
} // function getBestFitType()
public function getBestFitType() {
public function getBestFitType()
{
return $this->_bestFitType;
} // function getBestFitType()
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return False;
public function getValueOfYForX($xValue)
{
return false;
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return False;
public function getValueOfXForY($yValue)
{
return false;
} // function getValueOfXForY()
/**
* Return the original set of X-Values
*
* @return float[] X-Values
*/
public function getXValues() {
public function getXValues()
{
return $this->_xValues;
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
return False;
} // function getEquation()
/**
* Return the Slope of the line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlope($dp=0) {
public function getSlope($dp = 0)
{
if ($dp != 0) {
return round($this->_slope, $dp);
}
return $this->_slope;
} // function getSlope()
/**
* Return the standard error of the Slope
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlopeSE($dp=0) {
public function getSlopeSE($dp = 0)
{
if ($dp != 0) {
return round($this->_slopeSE, $dp);
}
return $this->_slopeSE;
} // function getSlopeSE()
/**
* Return the Value of X where it intersects Y = 0
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersect($dp=0) {
public function getIntersect($dp=0)
{
if ($dp != 0) {
return round($this->_intersect, $dp);
}
return $this->_intersect;
} // function getIntersect()
/**
* Return the standard error of the Intersect
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersectSE($dp=0) {
public function getIntersectSE($dp = 0)
{
if ($dp != 0) {
return round($this->_intersectSE, $dp);
}
return $this->_intersectSE;
} // function getIntersectSE()
/**
* Return the goodness of fit for this regression
*
* @param int $dp Number of places of decimal precision to return
* @return float
*/
public function getGoodnessOfFit($dp=0) {
public function getGoodnessOfFit($dp = 0)
{
if ($dp != 0) {
return round($this->_goodnessOfFit, $dp);
}
return $this->_goodnessOfFit;
} // function getGoodnessOfFit()
public function getGoodnessOfFitPercent($dp=0) {
public function getGoodnessOfFitPercent($dp = 0)
{
if ($dp != 0) {
return round($this->_goodnessOfFit * 100, $dp);
}
return $this->_goodnessOfFit * 100;
} // function getGoodnessOfFitPercent()
/**
* Return the standard deviation of the residuals for this regression
*
* @param int $dp Number of places of decimal precision to return
* @return float
*/
public function getStdevOfResiduals($dp=0) {
public function getStdevOfResiduals($dp = 0)
{
if ($dp != 0) {
return round($this->_stdevOfResiduals, $dp);
}
return $this->_stdevOfResiduals;
} // function getStdevOfResiduals()
public function getSSRegression($dp=0) {
public function getSSRegression($dp = 0)
{
if ($dp != 0) {
return round($this->_SSRegression, $dp);
}
return $this->_SSRegression;
} // function getSSRegression()
public function getSSResiduals($dp=0) {
public function getSSResiduals($dp = 0)
{
if ($dp != 0) {
return round($this->_SSResiduals, $dp);
}
return $this->_SSResiduals;
} // function getSSResiduals()
public function getDFResiduals($dp=0) {
public function getDFResiduals($dp = 0)
{
if ($dp != 0) {
return round($this->_DFResiduals, $dp);
}
return $this->_DFResiduals;
} // function getDFResiduals()
public function getF($dp=0) {
public function getF($dp = 0)
{
if ($dp != 0) {
return round($this->_F, $dp);
}
return $this->_F;
} // function getF()
public function getCovariance($dp=0) {
public function getCovariance($dp = 0)
{
if ($dp != 0) {
return round($this->_covariance, $dp);
}
return $this->_covariance;
} // function getCovariance()
public function getCorrelation($dp=0) {
public function getCorrelation($dp = 0)
{
if ($dp != 0) {
return round($this->_correlation, $dp);
}
return $this->_correlation;
} // function getCorrelation()
public function getYBestFitValues() {
public function getYBestFitValues()
{
return $this->_yBestFitValues;
} // function getYBestFitValues()
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) {
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
{
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach ($this->_xValues as $xKey => $xValue) {
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
@ -364,8 +365,8 @@ class PHPExcel_Best_Fit
}
} // function _calculateGoodnessOfFit()
protected function _leastSquareFit($yValues, $xValues, $const) {
protected function _leastSquareFit($yValues, $xValues, $const)
{
// calculate sums
$x_sum = array_sum($xValues);
$y_sum = array_sum($yValues);
@ -401,7 +402,6 @@ class PHPExcel_Best_Fit
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
} // function _leastSquareFit()
/**
* Define the regression
*
@ -409,7 +409,8 @@ class PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($yValues, $xValues=array(), $const=True) {
function __construct($yValues, $xValues = array(), $const = true)
{
// Calculate number of points
$nY = count($yValues);
$nX = count($xValues);
@ -420,13 +421,12 @@ class PHPExcel_Best_Fit
$nX = $nY;
} elseif ($nY != $nX) {
// Ensure both arrays of points are the same size
$this->_error = True;
return False;
$this->_error = true;
return false;
}
$this->_valueCount = $nY;
$this->_xValues = $xValues;
$this->_yValues = $yValues;
} // function __construct()
} // class bestFit
}

View File

@ -46,71 +46,70 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/
protected $_bestFitType = 'exponential';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
**/
public function getValueOfYForX($xValue) {
public function getValueOfYForX($xValue)
{
return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset));
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
public function getValueOfXForY($yValue)
{
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' * '.$slope.'^X';
} // function getEquation()
/**
* Return the Slope of the line
*
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getSlope($dp=0) {
public function getSlope($dp = 0)
{
if ($dp != 0) {
return round(exp($this->_slope), $dp);
}
return exp($this->_slope);
} // function getSlope()
/**
* Return the Value of X where it intersects Y = 0
*
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getIntersect($dp=0) {
public function getIntersect($dp = 0)
{
if ($dp != 0) {
return round(exp($this->_intersect), $dp);
}
return exp($this->_intersect);
} // function getIntersect()
/**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -118,7 +117,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
private function _exponential_regression($yValues, $xValues, $const) {
private function _exponential_regression($yValues, $xValues, $const)
{
foreach ($yValues as &$value) {
if ($value < 0.0) {
$value = 0 - log(abs($value));
@ -131,7 +131,6 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
$this->_leastSquareFit($yValues, $xValues, $const);
} // function _exponential_regression()
/**
* Define the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -139,10 +138,10 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($yValues, $xValues=array(), $const=True) {
if (parent::__construct($yValues, $xValues) !== False) {
function __construct($yValues, $xValues = array(), $const = true)
{
if (parent::__construct($yValues, $xValues) !== false) {
$this->_exponential_regression($yValues, $xValues, $const);
}
} // function __construct()
} // class exponentialBestFit
}

View File

@ -25,10 +25,8 @@
* @version ##VERSION##, ##DATE##
*/
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
/**
* PHPExcel_Linear_Best_Fit
*
@ -46,25 +44,25 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
**/
protected $_bestFitType = 'linear';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
**/
public function getValueOfYForX($xValue) {
public function getValueOfYForX($xValue)
{
return $this->getIntersect() + $this->getSlope() * $xValue;
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
public function getValueOfXForY($yValue)
{
return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY()
@ -75,14 +73,14 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' + '.$slope.' * X';
} // function getEquation()
/**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -90,11 +88,11 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
private function _linear_regression($yValues, $xValues, $const) {
private function _linear_regression($yValues, $xValues, $const)
{
$this->_leastSquareFit($yValues, $xValues, $const);
} // function _linear_regression()
/**
* Define the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -102,10 +100,10 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($yValues, $xValues=array(), $const=True) {
if (parent::__construct($yValues, $xValues) !== False) {
function __construct($yValues, $xValues = array(), $const = true)
{
if (parent::__construct($yValues, $xValues) !== false) {
$this->_linear_regression($yValues, $xValues, $const);
}
} // function __construct()
} // class linearBestFit
}

View File

@ -25,10 +25,8 @@
* @version ##VERSION##, ##DATE##
*/
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
/**
* PHPExcel_Logarithmic_Best_Fit
*
@ -46,43 +44,42 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
**/
protected $_bestFitType = 'logarithmic';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
**/
public function getValueOfYForX($xValue) {
public function getValueOfYForX($xValue)
{
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
public function getValueOfXForY($yValue)
{
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' + '.$slope.' * log(X)';
} // function getEquation()
/**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -90,7 +87,8 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
private function _logarithmic_regression($yValues, $xValues, $const) {
private function _logarithmic_regression($yValues, $xValues, $const)
{
foreach ($xValues as &$value) {
if ($value < 0.0) {
$value = 0 - log(abs($value));
@ -103,7 +101,6 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
$this->_leastSquareFit($yValues, $xValues, $const);
} // function _logarithmic_regression()
/**
* Define the regression and calculate the goodness of fit for a set of X and Y data values
*
@ -111,10 +108,10 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($yValues, $xValues=array(), $const=True) {
if (parent::__construct($yValues, $xValues) !== False) {
function __construct($yValues, $xValues = array(), $const = true)
{
if (parent::__construct($yValues, $xValues) !== false) {
$this->_logarithmic_regression($yValues, $xValues, $const);
}
} // function __construct()
} // class logarithmicBestFit
}

View File

@ -61,7 +61,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
*
* @return int
**/
public function getOrder() {
public function getOrder()
{
return $this->_order;
} // function getOrder()
@ -72,7 +73,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float $xValue X-Value
* @return float Y-Value
**/
public function getValueOfYForX($xValue) {
public function getValueOfYForX($xValue)
{
$retVal = $this->getIntersect();
$slope = $this->getSlope();
foreach ($slope as $key => $value) {
@ -90,7 +92,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
public function getValueOfXForY($yValue)
{
return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY()
@ -101,7 +104,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
@ -124,7 +128,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getSlope($dp=0) {
public function getSlope($dp = 0)
{
if ($dp != 0) {
$coefficients = array();
foreach ($this->_slope as $coefficient) {
@ -136,7 +141,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
} // function getSlope()
public function getCoefficients($dp=0) {
public function getCoefficients($dp = 0)
{
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
} // function getCoefficients()
@ -149,7 +155,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
private function _polynomial_regression($order, $yValues, $xValues, $const) {
private function _polynomial_regression($order, $yValues, $xValues, $const)
{
// calculate sums
$x_sum = array_sum($xValues);
$y_sum = array_sum($yValues);
@ -206,8 +213,9 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($order, $yValues, $xValues=array(), $const=True) {
if (parent::__construct($yValues, $xValues) !== False) {
function __construct($order, $yValues, $xValues = array(), $const = true)
{
if (parent::__construct($yValues, $xValues) !== false) {
if ($order < $this->_valueCount) {
$this->_bestFitType .= '_'.$order;
$this->_order = $order;
@ -220,5 +228,4 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
}
}
} // function __construct()
} // class polynomialBestFit
}

View File

@ -53,7 +53,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float $xValue X-Value
* @return float Y-Value
**/
public function getValueOfYForX($xValue) {
public function getValueOfYForX($xValue)
{
return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
} // function getValueOfYForX()
@ -64,8 +65,9 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()),(1 / $this->getSlope()));
public function getValueOfXForY($yValue)
{
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()), (1 / $this->getSlope()));
} // function getValueOfXForY()
@ -75,7 +77,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getEquation($dp=0) {
public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
@ -89,7 +92,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display
* @return string
**/
public function getIntersect($dp=0) {
public function getIntersect($dp = 0)
{
if ($dp != 0) {
return round(exp($this->_intersect), $dp);
}
@ -104,7 +108,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
private function _power_regression($yValues, $xValues, $const) {
private function _power_regression($yValues, $xValues, $const)
{
foreach ($xValues as &$value) {
if ($value < 0.0) {
$value = 0 - log(abs($value));
@ -133,10 +138,10 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression
* @param boolean $const
*/
function __construct($yValues, $xValues=array(), $const=True) {
if (parent::__construct($yValues, $xValues) !== False) {
function __construct($yValues, $xValues = array(), $const = true)
{
if (parent::__construct($yValues, $xValues) !== false) {
$this->_power_regression($yValues, $xValues, $const);
}
} // function __construct()
} // class powerBestFit
}
}

View File

@ -84,7 +84,8 @@ class trendClass
private static $_trendCache = array();
public static function calculate($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const=True) {
public static function calculate($trendType = self::TREND_BEST_FIT, $yValues, $xValues = array(), $const = true)
{
// Calculate number of points in each dataset
$nY = count($yValues);
$nX = count($xValues);
@ -102,29 +103,29 @@ class trendClass
// Determine which trend method has been requested
switch ($trendType) {
// Instantiate and return the class for the requested trend method
case self::TREND_LINEAR :
case self::TREND_LOGARITHMIC :
case self::TREND_EXPONENTIAL :
case self::TREND_POWER :
case self::TREND_LINEAR:
case self::TREND_LOGARITHMIC:
case self::TREND_EXPONENTIAL:
case self::TREND_POWER:
if (!isset(self::$_trendCache[$key])) {
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
}
return self::$_trendCache[$key];
break;
case self::TREND_POLYNOMIAL_2 :
case self::TREND_POLYNOMIAL_3 :
case self::TREND_POLYNOMIAL_4 :
case self::TREND_POLYNOMIAL_5 :
case self::TREND_POLYNOMIAL_6 :
case self::TREND_POLYNOMIAL_2:
case self::TREND_POLYNOMIAL_3:
case self::TREND_POLYNOMIAL_4:
case self::TREND_POLYNOMIAL_5:
case self::TREND_POLYNOMIAL_6:
if (!isset(self::$_trendCache[$key])) {
$order = substr($trendType,-1);
$order = substr($trendType, -1);
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
}
return self::$_trendCache[$key];
break;
case self::TREND_BEST_FIT :
case self::TREND_BEST_FIT_NO_POLY :
case self::TREND_BEST_FIT:
case self::TREND_BEST_FIT_NO_POLY:
// If the request is to determine the best fit regression, then we test each trend line in turn
// Start by generating an instance of each available trend method
foreach (self::$_trendTypes as $trendMethod) {
@ -134,7 +135,7 @@ class trendClass
}
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
foreach (self::$_trendTypePolyOrders as $trendMethod) {
$order = substr($trendMethod,-1);
$order = substr($trendMethod, -1);
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
if ($bestFit[$trendMethod]->getError()) {
unset($bestFit[$trendMethod]);
@ -148,9 +149,8 @@ class trendClass
$bestFitType = key($bestFitValue);
return $bestFit[$bestFitType];
break;
default :
default:
return false;
}
} // function calculate()
} // class trendClass

View File

@ -434,8 +434,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) ||
(PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') ||
(PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) {
(PHPExcel_Shared_String::Substring($pValue, -1, 1)=='\'') ||
(PHPExcel_Shared_String::Substring($pValue, 0, 1)=='\'')) {
throw new PHPExcel_Exception('Invalid character found in sheet code name');
}
@ -2066,7 +2066,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$highestRow = $this->getHighestDataRow();
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
for($r = 0; $r < $pNumRows; ++$r) {
for ($r = 0; $r < $pNumRows; ++$r) {
$this->getCellCacheController()->removeRow($highestRow);
--$highestRow;
}
@ -2091,7 +2091,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
for($c = 0; $c < $pNumCols; ++$c) {
for ($c = 0; $c < $pNumCols; ++$c) {
$this->getCellCacheController()->removeColumn($highestColumn);
$highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2);
}
@ -2502,9 +2502,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
$returnValue[$rRef][$cRef],
($style && $style->getNumberFormat()) ?
$style->getNumberFormat()->getFormatCode() :
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
($style && $style->getNumberFormat()) ? $style->getNumberFormat()->getFormatCode() : PHPExcel_Style_NumberFormat::FORMAT_GENERAL
);
}
} else {
@ -2622,7 +2620,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Loop through column dimensions
foreach ($this->_columnDimensions as $dimension) {
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
$highestColumn = max($highestColumn, PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
}
// Loop through row dimensions
@ -2674,7 +2672,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
if ($returnRange) {
return array(trim(substr($pRange, 0, $sep),"'"), substr($pRange, $sep + 1));
return array(trim(substr($pRange, 0, $sep), "'"), substr($pRange, $sep + 1));
}
return substr($pRange, $sep + 1);
@ -2833,9 +2831,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getTabColor()
{
if ($this->_tabColor === null)
if ($this->_tabColor === null) {
$this->_tabColor = new PHPExcel_Style_Color();
}
return $this->_tabColor;
}
@ -2867,7 +2865,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel_Worksheet
*/
public function copy() {
public function copy()
{
$copied = clone $this;
return $copied;
@ -2908,7 +2907,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return objWorksheet
* @throws PHPExcel_Exception
*/
public function setCodeName($pValue=null)
public function setCodeName($pValue = null)
{
// Is this a 'rename' or not?
if ($this->getCodeName() == $pValue) {
@ -2927,18 +2926,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Use name, but append with lowest possible integer
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29);
}
$i = 1;
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
++$i;
if ($i == 10) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28);
}
} elseif ($i == 100) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27);
}
}
}

View File

@ -114,7 +114,7 @@ class PHPExcel_Worksheet_AutoFilter
public function setRange($pRange = '')
{
// Uppercase coordinate
$cellAddress = explode('!',strtoupper($pRange));
$cellAddress = explode('!', strtoupper($pRange));
if (count($cellAddress) > 1) {
list($worksheet, $pRange) = $cellAddress;
}
@ -349,7 +349,7 @@ class PHPExcel_Worksheet_AutoFilter
}
foreach ($dateSet as $dateValue) {
// Use of substr to extract value at the appropriate group level
if (substr($dtVal,0,strlen($dateValue)) == $dateValue) {
if (substr($dtVal, 0, strlen($dateValue)) == $dateValue) {
return true;
}
}
@ -381,34 +381,34 @@ class PHPExcel_Worksheet_AutoFilter
if (is_numeric($rule['value'])) {
// Numeric values are tested using the appropriate operator
switch ($rule['operator']) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
$retVal = ($cellValue == $rule['value']);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
$retVal = ($cellValue != $rule['value']);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN:
$retVal = ($cellValue > $rule['value']);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL:
$retVal = ($cellValue >= $rule['value']);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN:
$retVal = ($cellValue < $rule['value']);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL:
$retVal = ($cellValue <= $rule['value']);
break;
}
} elseif ($rule['value'] == '') {
switch ($rule['operator']) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
$retVal = (($cellValue == '') || ($cellValue === null));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
$retVal = (($cellValue != '') && ($cellValue !== null));
break;
default :
default:
$retVal = true;
break;
}
@ -418,7 +418,7 @@ class PHPExcel_Worksheet_AutoFilter
}
// If there are multiple conditions, then we need to test both using the appropriate join operator
switch ($join) {
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR:
$returnVal = $returnVal || $retVal;
// Break as soon as we have a TRUE match for OR joins,
// to avoid unnecessary additional code execution
@ -426,7 +426,7 @@ class PHPExcel_Worksheet_AutoFilter
return $returnVal;
}
break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND:
$returnVal = $returnVal && $retVal;
break;
}
@ -450,7 +450,7 @@ class PHPExcel_Worksheet_AutoFilter
}
if (is_numeric($cellValue)) {
$dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue));
$dateValue = date('m', PHPExcel_Shared_Date::ExcelToPHP($cellValue));
if (in_array($dateValue, $monthSet)) {
return true;
}
@ -485,69 +485,69 @@ class PHPExcel_Worksheet_AutoFilter
$baseDate = PHPExcel_Calculation_DateTime::DATENOW();
// Calculate start/end dates for the required date range based on current date
switch ($dynamicRuleType) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
$baseDate = strtotime('-7 days', $baseDate);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK:
$baseDate = strtotime('-7 days', $baseDate);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
$baseDate = strtotime('-1 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
$baseDate = strtotime('-1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
$baseDate = strtotime('+1 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH:
$baseDate = strtotime('+1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
$baseDate = strtotime('-3 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
$baseDate = strtotime('-3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
$baseDate = strtotime('+3 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER:
$baseDate = strtotime('+3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
$baseDate = strtotime('-1 year',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
$baseDate = strtotime('-1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
$baseDate = strtotime('+1 year',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR:
$baseDate = strtotime('+1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
}
switch ($dynamicRuleType) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate);
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE:
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR:
$maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate)));
++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER:
$thisMonth = date('m', $baseDate);
$thisQuarter = floor(--$thisMonth / 3);
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1+$thisQuarter)*3, date('Y', $baseDate)));
++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1+$thisQuarter*3, date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH:
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate)));
++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK:
$dayOfWeek = date('w', $baseDate);
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek;
$maxVal = $val + 7;
@ -556,11 +556,11 @@ class PHPExcel_Worksheet_AutoFilter
switch ($dynamicRuleType) {
// Adjust Today dates for Yesterday and Tomorrow
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY:
--$maxVal;
--$val;
break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
++$maxVal;
++$val;
break;
@ -589,7 +589,7 @@ class PHPExcel_Worksheet_AutoFilter
sort($dataValues);
}
return array_pop(array_slice($dataValues,0, $ruleValue));
return array_pop(array_slice($dataValues, 0, $ruleValue));
}
/**
@ -610,7 +610,7 @@ class PHPExcel_Worksheet_AutoFilter
foreach ($this->_columns as $columnID => $filterColumn) {
$rules = $filterColumn->getRules();
switch ($filterColumn->getFilterType()) {
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER:
$ruleValues = array();
// Build a list of the filter value selections
foreach ($rules as $rule) {
@ -620,8 +620,9 @@ class PHPExcel_Worksheet_AutoFilter
// Test if we want to include blanks in our filter criteria
$blanks = false;
$ruleDataSet = array_filter($ruleValues);
if (count($ruleValues) != count($ruleDataSet))
if (count($ruleValues) != count($ruleDataSet)) {
$blanks = true;
}
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) {
// Filter on absolute values
$columnFilterTests[$columnID] = array(
@ -638,23 +639,29 @@ class PHPExcel_Worksheet_AutoFilter
foreach ($ruleDataSet as $ruleValue) {
$date = $time = '';
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) {
$date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) {
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) {
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== ''))
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
}
$dateTime = $date . $time;
$arguments['date'][] = $date;
$arguments['time'][] = $time;
@ -670,7 +677,7 @@ class PHPExcel_Worksheet_AutoFilter
);
}
break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER:
$customRuleForBlanks = false;
$ruleValues = array();
// Build a list of the filter value selections
@ -680,7 +687,7 @@ class PHPExcel_Worksheet_AutoFilter
if (!is_numeric($ruleValue)) {
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
$ruleValue = preg_quote($ruleValue);
$ruleValue = str_replace(self::$_fromReplace,self::$_toReplace, $ruleValue);
$ruleValue = str_replace(self::$_fromReplace, self::$_toReplace, $ruleValue);
if (trim($ruleValue) == '') {
$customRuleForBlanks = true;
$ruleValue = trim($ruleValue);
@ -694,7 +701,7 @@ class PHPExcel_Worksheet_AutoFilter
'arguments' => array('filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks)
);
break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER:
$ruleValues = array();
foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway
@ -704,7 +711,7 @@ class PHPExcel_Worksheet_AutoFilter
// Number (Average) based
// Calculate the average
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,null, $this->_workSheet->getCell('A1'));
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula, null, $this->_workSheet->getCell('A1'));
// Set above/below rule based on greaterThan or LessTan
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
@ -720,14 +727,14 @@ class PHPExcel_Worksheet_AutoFilter
// Date based
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
// Month or Quarter
sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period);
sscanf($dynamicRuleType, '%[A-Z]%d', $periodType, $period);
if ($periodType == 'M') {
$ruleValues = array($period);
} else {
--$period;
$periodEnd = (1+$period)*3;
$periodStart = 1+$period*3;
$ruleValues = range($periodStart,periodEnd);
$ruleValues = range($periodStart, $periodEnd);
}
$columnFilterTests[$columnID] = array(
'method' => '_filterTestInPeriodDateSet',
@ -742,7 +749,7 @@ class PHPExcel_Worksheet_AutoFilter
}
}
break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER :
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER:
$ruleValues = array();
$dataRowCount = $rangeEnd[1] - $rangeStart[1];
foreach ($rules as $rule) {
@ -754,8 +761,12 @@ class PHPExcel_Worksheet_AutoFilter
if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) {
$ruleValue = floor($ruleValue * ($dataRowCount / 100));
}
if ($ruleValue < 1) $ruleValue = 1;
if ($ruleValue > 500) $ruleValue = 500;
if ($ruleValue < 1) {
$ruleValue = 1;
}
if ($ruleValue > 500) {
$ruleValue = 500;
}
$maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
@ -836,7 +847,8 @@ class PHPExcel_Worksheet_AutoFilter
* toString method replicates previous behavior by returning the range if object is
* referenced as a property of its parent.
*/
public function __toString() {
public function __toString()
{
return (string) $this->_range;
}
}

View File

@ -366,7 +366,8 @@ class PHPExcel_Worksheet_PageSetup
*
* @return boolean
*/
public function getFitToPage() {
public function getFitToPage()
{
return $this->_fitToPage;
}