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,7 +93,8 @@ 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))) . '_';
@ -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,7 +351,8 @@ class PHPExcel_Shared_String
* @param string $value Value to unescape
* @return string
*/
public static function ControlCharacterOOXML2PHP($value = '') {
public static function ControlCharacterOOXML2PHP($value = '')
{
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value);
}
@ -370,7 +370,8 @@ class PHPExcel_Shared_String
* @param string $value Value to escape
* @return string
*/
public static function ControlCharacterPHP2OOXML($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;
@ -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,7 +65,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float $yValue Y-Value
* @return float X-Value
**/
public function getValueOfXForY($yValue) {
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);
@ -152,5 +153,4 @@ class trendClass
return false;
}
} // function calculate()
} // class trendClass

View File

@ -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 {
@ -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;

View File

@ -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;
@ -727,7 +734,7 @@ class PHPExcel_Worksheet_AutoFilter
--$period;
$periodEnd = (1+$period)*3;
$periodStart = 1+$period*3;
$ruleValues = range($periodStart,periodEnd);
$ruleValues = range($periodStart, $periodEnd);
}
$columnFilterTests[$columnID] = array(
'method' => '_filterTestInPeriodDateSet',
@ -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;
}