29require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/linearBestFitClass.php';
 
   30require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/logarithmicBestFitClass.php';
 
   31require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/exponentialBestFitClass.php';
 
   32require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/powerBestFitClass.php';
 
   33require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/polynomialBestFitClass.php';
 
   63                                                                                 self::TREND_LOGARITHMIC,
 
   64                                                                                 self::TREND_EXPONENTIAL,
 
   73                                                                                                  self::TREND_POLYNOMIAL_3,
 
   74                                                                                                  self::TREND_POLYNOMIAL_4,
 
   75                                                                                                  self::TREND_POLYNOMIAL_5,
 
   76                                                                                                  self::TREND_POLYNOMIAL_6
 
   87        public static function calculate($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const=True) {
 
   89                $nY = count($yValues);
 
   90                $nX = count($xValues);
 
   94                        $xValues = range(1,$nY);
 
   96                } elseif ($nY != $nX) {
 
   98                        trigger_error(
"trend(): Number of elements in coordinate arrays do not match.", E_USER_ERROR);
 
  101                $key = md5($trendType.$const.serialize($yValues).serialize($xValues));
 
  103                switch ($trendType) {
 
  109                                if (!isset(self::$_trendCache[
$key])) {
 
  110                                        $className = 
'PHPExcel_'.$trendType.
'_Best_Fit';
 
  111                                        self::$_trendCache[
$key] = 
new $className($yValues,$xValues,$const);
 
  113                                return self::$_trendCache[
$key];
 
  120                                if (!isset(self::$_trendCache[
$key])) {
 
  121                                        $order = substr($trendType,-1);
 
  124                                return self::$_trendCache[
$key];
 
  130                                foreach(self::$_trendTypes as $trendMethod) {
 
  131                                        $className = 
'PHPExcel_'.$trendMethod.
'BestFit';
 
  132                                        $bestFit[$trendMethod] = 
new $className($yValues,$xValues,$const);
 
  133                                        $bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
 
  135                                if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
 
  136                                        foreach(self::$_trendTypePolyOrders as $trendMethod) {
 
  137                                                $order = substr($trendMethod,-1);
 
  139                                                if ($bestFit[$trendMethod]->
getError()) {
 
  140                                                        unset($bestFit[$trendMethod]);
 
  142                                                        $bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
 
  147                                arsort($bestFitValue);
 
  148                                $bestFitType = key($bestFitValue);
 
  149                                return $bestFit[$bestFitType];
 
An exception for terminatinating execution or to throw for unit testing.
getError()
returns error @access public
static calculate($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const=True)
const TREND_BEST_FIT_NO_POLY
static $_trendTypePolyOrders