Skip to content

Commit 2eaf9b5

Browse files
author
Mark Baker
authored
Start splitting some of the basic Statistical functions out into separate classes (#1888)
* Start splitting some of the basic Statistical functions out into separate classes containing just a few similar functions * Splitting some of the basic Statistical functions out into separate classes containing just a few similar functions - MAX(), MAXA(), MIN() and MINA() * Splitting some more of the basic Statistical functions out into separate classes containing just a few similar functions - StandardDeviations and Variances
1 parent 8721f79 commit 2eaf9b5

38 files changed

+1314
-580
lines changed

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,17 @@ class Calculation
328328
],
329329
'AVEDEV' => [
330330
'category' => Category::CATEGORY_STATISTICAL,
331-
'functionCall' => [Statistical::class, 'AVEDEV'],
331+
'functionCall' => [Statistical\Averages::class, 'AVEDEV'],
332332
'argumentCount' => '1+',
333333
],
334334
'AVERAGE' => [
335335
'category' => Category::CATEGORY_STATISTICAL,
336-
'functionCall' => [Statistical::class, 'AVERAGE'],
336+
'functionCall' => [Statistical\Averages::class, 'AVERAGE'],
337337
'argumentCount' => '1+',
338338
],
339339
'AVERAGEA' => [
340340
'category' => Category::CATEGORY_STATISTICAL,
341-
'functionCall' => [Statistical::class, 'AVERAGEA'],
341+
'functionCall' => [Statistical\Averages::class, 'AVERAGEA'],
342342
'argumentCount' => '1+',
343343
],
344344
'AVERAGEIF' => [
@@ -624,17 +624,17 @@ class Calculation
624624
],
625625
'COUNT' => [
626626
'category' => Category::CATEGORY_STATISTICAL,
627-
'functionCall' => [Statistical::class, 'COUNT'],
627+
'functionCall' => [Statistical\Counts::class, 'COUNT'],
628628
'argumentCount' => '1+',
629629
],
630630
'COUNTA' => [
631631
'category' => Category::CATEGORY_STATISTICAL,
632-
'functionCall' => [Statistical::class, 'COUNTA'],
632+
'functionCall' => [Statistical\Counts::class, 'COUNTA'],
633633
'argumentCount' => '1+',
634634
],
635635
'COUNTBLANK' => [
636636
'category' => Category::CATEGORY_STATISTICAL,
637-
'functionCall' => [Statistical::class, 'COUNTBLANK'],
637+
'functionCall' => [Statistical\Counts::class, 'COUNTBLANK'],
638638
'argumentCount' => '1',
639639
],
640640
'COUNTIF' => [
@@ -1620,12 +1620,12 @@ class Calculation
16201620
],
16211621
'MAX' => [
16221622
'category' => Category::CATEGORY_STATISTICAL,
1623-
'functionCall' => [Statistical::class, 'MAX'],
1623+
'functionCall' => [Statistical\Maximum::class, 'MAX'],
16241624
'argumentCount' => '1+',
16251625
],
16261626
'MAXA' => [
16271627
'category' => Category::CATEGORY_STATISTICAL,
1628-
'functionCall' => [Statistical::class, 'MAXA'],
1628+
'functionCall' => [Statistical\Maximum::class, 'MAXA'],
16291629
'argumentCount' => '1+',
16301630
],
16311631
'MAXIFS' => [
@@ -1665,12 +1665,12 @@ class Calculation
16651665
],
16661666
'MIN' => [
16671667
'category' => Category::CATEGORY_STATISTICAL,
1668-
'functionCall' => [Statistical::class, 'MIN'],
1668+
'functionCall' => [Statistical\Minimum::class, 'MIN'],
16691669
'argumentCount' => '1+',
16701670
],
16711671
'MINA' => [
16721672
'category' => Category::CATEGORY_STATISTICAL,
1673-
'functionCall' => [Statistical::class, 'MINA'],
1673+
'functionCall' => [Statistical\Minimum::class, 'MINA'],
16741674
'argumentCount' => '1+',
16751675
],
16761676
'MINIFS' => [
@@ -2263,22 +2263,22 @@ class Calculation
22632263
],
22642264
'STDEV' => [
22652265
'category' => Category::CATEGORY_STATISTICAL,
2266-
'functionCall' => [Statistical::class, 'STDEV'],
2266+
'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],
22672267
'argumentCount' => '1+',
22682268
],
22692269
'STDEV.S' => [
22702270
'category' => Category::CATEGORY_STATISTICAL,
2271-
'functionCall' => [Statistical::class, 'STDEV'],
2271+
'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],
22722272
'argumentCount' => '1+',
22732273
],
22742274
'STDEV.P' => [
22752275
'category' => Category::CATEGORY_STATISTICAL,
2276-
'functionCall' => [Statistical::class, 'STDEVP'],
2276+
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'],
22772277
'argumentCount' => '1+',
22782278
],
22792279
'STDEVA' => [
22802280
'category' => Category::CATEGORY_STATISTICAL,
2281-
'functionCall' => [Statistical::class, 'STDEVA'],
2281+
'functionCall' => [Statistical\StandardDeviations::class, 'STDEVA'],
22822282
'argumentCount' => '1+',
22832283
],
22842284
'STDEVP' => [
@@ -2524,32 +2524,32 @@ class Calculation
25242524
],
25252525
'VAR' => [
25262526
'category' => Category::CATEGORY_STATISTICAL,
2527-
'functionCall' => [Statistical::class, 'VARFunc'],
2527+
'functionCall' => [Statistical\Variances::class, 'VAR'],
25282528
'argumentCount' => '1+',
25292529
],
25302530
'VAR.P' => [
25312531
'category' => Category::CATEGORY_STATISTICAL,
2532-
'functionCall' => [Statistical::class, 'VARP'],
2532+
'functionCall' => [Statistical\Variances::class, 'VARP'],
25332533
'argumentCount' => '1+',
25342534
],
25352535
'VAR.S' => [
25362536
'category' => Category::CATEGORY_STATISTICAL,
2537-
'functionCall' => [Statistical::class, 'VARFunc'],
2537+
'functionCall' => [Statistical\Variances::class, 'VAR'],
25382538
'argumentCount' => '1+',
25392539
],
25402540
'VARA' => [
25412541
'category' => Category::CATEGORY_STATISTICAL,
2542-
'functionCall' => [Statistical::class, 'VARA'],
2542+
'functionCall' => [Statistical\Variances::class, 'VARA'],
25432543
'argumentCount' => '1+',
25442544
],
25452545
'VARP' => [
25462546
'category' => Category::CATEGORY_STATISTICAL,
2547-
'functionCall' => [Statistical::class, 'VARP'],
2547+
'functionCall' => [Statistical\Variances::class, 'VARP'],
25482548
'argumentCount' => '1+',
25492549
],
25502550
'VARPA' => [
25512551
'category' => Category::CATEGORY_STATISTICAL,
2552-
'functionCall' => [Statistical::class, 'VARPA'],
2552+
'functionCall' => [Statistical\Variances::class, 'VARPA'],
25532553
'argumentCount' => '1+',
25542554
],
25552555
'VDB' => [

src/PhpSpreadsheet/Calculation/Database/DAverage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Averages;
66

77
class DAverage extends DatabaseAbstract
88
{
@@ -38,7 +38,7 @@ public static function evaluate($database, $field, $criteria)
3838
return null;
3939
}
4040

41-
return Statistical::AVERAGE(
41+
return Averages::AVERAGE(
4242
self::getFilteredColumn($database, $field, $criteria)
4343
);
4444
}

src/PhpSpreadsheet/Calculation/Database/DCount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts;
66

77
class DCount extends DatabaseAbstract
88
{
@@ -36,7 +36,7 @@ public static function evaluate($database, $field, $criteria)
3636
{
3737
$field = self::fieldExtract($database, $field);
3838

39-
return Statistical::COUNT(
39+
return Counts::COUNT(
4040
self::getFilteredColumn($database, $field, $criteria)
4141
);
4242
}

src/PhpSpreadsheet/Calculation/Database/DCountA.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Counts;
66

77
class DCountA extends DatabaseAbstract
88
{
@@ -35,7 +35,7 @@ public static function evaluate($database, $field, $criteria)
3535
{
3636
$field = self::fieldExtract($database, $field);
3737

38-
return Statistical::COUNTA(
38+
return Counts::COUNTA(
3939
self::getFilteredColumn($database, $field ?? 0, $criteria)
4040
);
4141
}

src/PhpSpreadsheet/Calculation/Database/DMax.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Maximum;
66

77
class DMax extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::MAX(
42+
return Maximum::MAX(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

src/PhpSpreadsheet/Calculation/Database/DMin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Minimum;
66

77
class DMin extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::MIN(
42+
return Minimum::MIN(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

src/PhpSpreadsheet/Calculation/Database/DStDev.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations;
66

77
class DStDev extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::STDEV(
42+
return StandardDeviations::STDEV(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

src/PhpSpreadsheet/Calculation/Database/DStDevP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\StandardDeviations;
66

77
class DStDevP extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::STDEVP(
42+
return StandardDeviations::STDEVP(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

src/PhpSpreadsheet/Calculation/Database/DVar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances;
66

77
class DVar extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::VARFunc(
42+
return Variances::VAR(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

src/PhpSpreadsheet/Calculation/Database/DVarP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Calculation\Database;
44

5-
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
5+
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Variances;
66

77
class DVarP extends DatabaseAbstract
88
{
@@ -39,7 +39,7 @@ public static function evaluate($database, $field, $criteria)
3939
return null;
4040
}
4141

42-
return Statistical::VARP(
42+
return Variances::VARP(
4343
self::getFilteredColumn($database, $field, $criteria)
4444
);
4545
}

0 commit comments

Comments
 (0)