1: <?php
2: declare(strict_types=1);
3:
4: namespace om\RRule;
5:
6: /**
7: * FREQ rule part (RFC 5545, section 3.3.10).
8: */
9: enum Frequency: string {
10: case Yearly = 'YEARLY';
11: case Monthly = 'MONTHLY';
12: case Weekly = 'WEEKLY';
13: case Daily = 'DAILY';
14: case Hourly = 'HOURLY';
15: case Minutely = 'MINUTELY';
16: case Secondly = 'SECONDLY';
17:
18: /**
19: * True when this frequency is coarser than the given one (e.g. YEARLY is coarser than DAILY).
20: */
21: public function isCoarserThan(self $other): bool {
22: return $this->rank() < $other->rank();
23: }
24:
25: private function rank(): int {
26: return match ($this) {
27: self::Yearly => 0,
28: self::Monthly => 1,
29: self::Weekly => 2,
30: self::Daily => 3,
31: self::Hourly => 4,
32: self::Minutely => 5,
33: self::Secondly => 6,
34: };
35: }
36: }
37: