Email_Chart.php
5 months ago
Email_Reports.php
5 months ago
Interval.php
5 months ago
Interval_Factory.php
2 years ago
Interval_Factory.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Email_Reports; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Interval_Factory |
| 7 | { |
| 8 | public static function from_option() : \IAWP\Email_Reports\Interval |
| 9 | { |
| 10 | $interval_id = \get_option('iawp_email_report_interval', 'monthly'); |
| 11 | switch ($interval_id) { |
| 12 | case 'daily': |
| 13 | return \IAWP\Email_Reports\Interval_Factory::daily(); |
| 14 | case 'weekly': |
| 15 | return \IAWP\Email_Reports\Interval_Factory::weekly(); |
| 16 | default: |
| 17 | return \IAWP\Email_Reports\Interval_Factory::monthly(); |
| 18 | } |
| 19 | } |
| 20 | public static function daily() : \IAWP\Email_Reports\Interval |
| 21 | { |
| 22 | return new \IAWP\Email_Reports\Interval(['id' => 'daily', 'relative_date_range_id' => 'TODAY', 'datetime_format_pattern' => 'l, M jS', 'chart_title' => \__('Hourly Views', 'independent-analytics')]); |
| 23 | } |
| 24 | public static function weekly() : \IAWP\Email_Reports\Interval |
| 25 | { |
| 26 | return new \IAWP\Email_Reports\Interval(['id' => 'weekly', 'relative_date_range_id' => 'THIS_WEEK', 'datetime_prefix' => \__('Week of', 'independent-analytics'), 'datetime_format_pattern' => 'l, M jS', 'chart_title' => \__('Daily Views', 'independent-analytics')]); |
| 27 | } |
| 28 | public static function monthly() : \IAWP\Email_Reports\Interval |
| 29 | { |
| 30 | return new \IAWP\Email_Reports\Interval(['id' => 'monthly', 'relative_date_range_id' => 'THIS_MONTH', 'datetime_format_pattern' => 'F Y', 'chart_title' => \__('Daily Views', 'independent-analytics')]); |
| 31 | } |
| 32 | } |
| 33 |