Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start splitting some of the basic Statistical functions out into separate classes #1888

Merged
merged 16 commits into from
Mar 2, 2021
Merged
40 changes: 20 additions & 20 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,17 @@ class Calculation
],
'AVEDEV' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'AVEDEV'],
'functionCall' => [Statistical\Averages::class, 'AVEDEV'],
'argumentCount' => '1+',
],
'AVERAGE' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'AVERAGE'],
'functionCall' => [Statistical\Averages::class, 'AVERAGE'],
'argumentCount' => '1+',
],
'AVERAGEA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'AVERAGEA'],
'functionCall' => [Statistical\Averages::class, 'AVERAGEA'],
'argumentCount' => '1+',
],
'AVERAGEIF' => [
Expand Down Expand Up @@ -624,17 +624,17 @@ class Calculation
],
'COUNT' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'COUNT'],
'functionCall' => [Statistical\Counts::class, 'COUNT'],
'argumentCount' => '1+',
],
'COUNTA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'COUNTA'],
'functionCall' => [Statistical\Counts::class, 'COUNTA'],
'argumentCount' => '1+',
],
'COUNTBLANK' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'COUNTBLANK'],
'functionCall' => [Statistical\Counts::class, 'COUNTBLANK'],
'argumentCount' => '1',
],
'COUNTIF' => [
Expand Down Expand Up @@ -1620,12 +1620,12 @@ class Calculation
],
'MAX' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'MAX'],
'functionCall' => [Statistical\Maximum::class, 'MAX'],
'argumentCount' => '1+',
],
'MAXA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'MAXA'],
'functionCall' => [Statistical\Maximum::class, 'MAXA'],
'argumentCount' => '1+',
],
'MAXIFS' => [
Expand Down Expand Up @@ -1665,12 +1665,12 @@ class Calculation
],
'MIN' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'MIN'],
'functionCall' => [Statistical\Minimum::class, 'MIN'],
'argumentCount' => '1+',
],
'MINA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'MINA'],
'functionCall' => [Statistical\Minimum::class, 'MINA'],
'argumentCount' => '1+',
],
'MINIFS' => [
Expand Down Expand Up @@ -2263,22 +2263,22 @@ class Calculation
],
'STDEV' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEV'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],
'argumentCount' => '1+',
],
'STDEV.S' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEV'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],
'argumentCount' => '1+',
],
'STDEV.P' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEVP'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'],
'argumentCount' => '1+',
],
'STDEVA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'STDEVA'],
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVA'],
'argumentCount' => '1+',
],
'STDEVP' => [
Expand Down Expand Up @@ -2524,32 +2524,32 @@ class Calculation
],
'VAR' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARFunc'],
'functionCall' => [Statistical\Variances::class, 'VAR'],
'argumentCount' => '1+',
],
'VAR.P' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARP'],
'functionCall' => [Statistical\Variances::class, 'VARP'],
'argumentCount' => '1+',
],
'VAR.S' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARFunc'],
'functionCall' => [Statistical\Variances::class, 'VAR'],
'argumentCount' => '1+',
],
'VARA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARA'],
'functionCall' => [Statistical\Variances::class, 'VARA'],
'argumentCount' => '1+',
],
'VARP' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARP'],
'functionCall' => [Statistical\Variances::class, 'VARP'],
'argumentCount' => '1+',
],
'VARPA' => [
'category' => Category::CATEGORY_STATISTICAL,
'functionCall' => [Statistical::class, 'VARPA'],
'functionCall' => [Statistical\Variances::class, 'VARPA'],
'argumentCount' => '1+',
],
'VDB' => [
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DAverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages;

class DAverage extends DatabaseAbstract
{
Expand Down Expand Up @@ -38,7 +38,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::AVERAGE(
return Averages::AVERAGE(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts;

class DCount extends DatabaseAbstract
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public static function evaluate($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);

return Statistical::COUNT(
return Counts::COUNT(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DCountA.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts;

class DCountA extends DatabaseAbstract
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public static function evaluate($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);

return Statistical::COUNTA(
return Counts::COUNTA(
self::getFilteredColumn($database, $field ?? 0, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DMax.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Maximum;

class DMax extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::MAX(
return Maximum::MAX(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DMin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Minimum;

class DMin extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::MIN(
return Minimum::MIN(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DStDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations;

class DStDev extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::STDEV(
return StandardDeviations::STDEV(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DStDevP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations;

class DStDevP extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::STDEVP(
return StandardDeviations::STDEVP(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances;

class DVar extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::VARFunc(
return Variances::VAR(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/Database/DVarP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Calculation\Database;

use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances;

class DVarP extends DatabaseAbstract
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
return null;
}

return Statistical::VARP(
return Variances::VARP(
self::getFilteredColumn($database, $field, $criteria)
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/PhpSpreadsheet/Calculation/MathTrig.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,27 +1222,27 @@ public static function SUBTOTAL($functionType, ...$args)
$aArgs = self::filterFormulaArgs($cellReference, $aArgs);
switch ($subtotal) {
case 1:
return Statistical::AVERAGE($aArgs);
return Statistical\Averages::AVERAGE($aArgs);
case 2:
return Statistical::COUNT($aArgs);
return Statistical\Counts::COUNT($aArgs);
case 3:
return Statistical::COUNTA($aArgs);
return Statistical\Counts::COUNTA($aArgs);
case 4:
return Statistical::MAX($aArgs);
return Statistical\Maximum::MAX($aArgs);
case 5:
return Statistical::MIN($aArgs);
return Statistical\Minimum::MIN($aArgs);
case 6:
return self::PRODUCT($aArgs);
case 7:
return Statistical::STDEV($aArgs);
return Statistical\StandardDeviations::STDEV($aArgs);
case 8:
return Statistical::STDEVP($aArgs);
return Statistical\StandardDeviations::STDEVP($aArgs);
case 9:
return self::SUM($aArgs);
case 10:
return Statistical::VARFunc($aArgs);
return Statistical\Variances::VAR($aArgs);
case 11:
return Statistical::VARP($aArgs);
return Statistical\Variances::VARP($aArgs);
}
}

Expand Down
Loading