From 106478b8d4d4843e54bee8fde6b6f391d9def1f8 Mon Sep 17 00:00:00 2001 From: eliseekn Date: Tue, 22 Aug 2023 23:17:39 +0000 Subject: [PATCH] Add new exception Add new period method --- README.md | 2 ++ src/Exceptions/InvalidPeriodException.php | 16 ++++++++++++++++ src/LaravelMetrics.php | 14 ++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/Exceptions/InvalidPeriodException.php diff --git a/README.md b/README.md index 5601896..c81cda0 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ LaravelMetrics::query( ->byDay($count = 0) ->byMonth($count = 0) ->byYear($count = 0) +->by($period, $count = 0) ->between($startDate, $endDate) ``` @@ -77,6 +78,7 @@ LaravelMetrics::query( $count = 0 => for every day, month or year $count = 1 => for the current day, month or year $count > 1 => for an interval of day, month or year from the $count value to now +$period = 'day', 'month' or 'year' ``` ### Types of aggregates diff --git a/src/Exceptions/InvalidPeriodException.php b/src/Exceptions/InvalidPeriodException.php new file mode 100644 index 0000000..9e672a4 --- /dev/null +++ b/src/Exceptions/InvalidPeriodException.php @@ -0,0 +1,16 @@ +period = $period; + $this->count = $count; + return $this; + } + public function between(string $start, string $end): self { $this->checkDateFormat([$start, $end]);