From cfaebbecc404fdfd3973810cff5762b0bebf6726 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 5 Apr 2023 17:42:02 +0000 Subject: [PATCH] - Minor enhancements --- src/Common/Sql.php | 3 ++- src/EntityCollection.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Common/Sql.php b/src/Common/Sql.php index cd02dc3..7ee3a98 100644 --- a/src/Common/Sql.php +++ b/src/Common/Sql.php @@ -56,7 +56,8 @@ abstract class Sql { $this->identifier = $identifier; } - public function __toString() { + public function __toString() : string + { return $this->identifier; } }; diff --git a/src/EntityCollection.php b/src/EntityCollection.php index 1802787..7c6216e 100644 --- a/src/EntityCollection.php +++ b/src/EntityCollection.php @@ -222,6 +222,11 @@ class EntityCollection extends \ArrayObject { return $list; } + public function sum($field) : float|int + { + return array_sum($this->column($field)); + } + public function unique(\Stringable|callable|string $field, bool $strict = false) : self { $list = [];