-
-
Notifications
You must be signed in to change notification settings - Fork 466
Expand file tree
/
Copy pathMonitorScheduleUnit.php
More file actions
67 lines (53 loc) · 1.24 KB
/
MonitorScheduleUnit.php
File metadata and controls
67 lines (53 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace Sentry;
final class MonitorScheduleUnit
{
/**
* @var string The value of the enum instance
*/
private $value;
/**
* @var array<string, self> A list of cached enum instances
*/
private static $instances = [];
private function __construct(string $value)
{
$this->value = $value;
}
public static function minute(): self
{
return self::getInstance('minute');
}
public static function hour(): self
{
return self::getInstance('hour');
}
public static function day(): self
{
return self::getInstance('day');
}
public static function week(): self
{
return self::getInstance('week');
}
public static function month(): self
{
return self::getInstance('month');
}
public static function year(): self
{
return self::getInstance('year');
}
public function __toString(): string
{
return $this->value;
}
private static function getInstance(string $value): self
{
if (!isset(self::$instances[$value])) {
self::$instances[$value] = new self($value);
}
return self::$instances[$value];
}
}