| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
final class MonitorScheduleUnit implements \Stringable |
| 7 |
{ |
| 8 |
/** |
| 9 |
* @var string The value of the enum instance |
| 10 |
*/ |
| 11 |
private $value; |
| 12 |
/** |
| 13 |
* @var array<string, self> A list of cached enum instances |
| 14 |
*/ |
| 15 |
private static $instances = []; |
| 16 |
private function __construct(string $value) |
| 17 |
{ |
| 18 |
$this->value = $value; |
| 19 |
} |
| 20 |
public static function minute() : self |
| 21 |
{ |
| 22 |
return self::getInstance('minute'); |
| 23 |
} |
| 24 |
public static function hour() : self |
| 25 |
{ |
| 26 |
return self::getInstance('hour'); |
| 27 |
} |
| 28 |
public static function day() : self |
| 29 |
{ |
| 30 |
return self::getInstance('day'); |
| 31 |
} |
| 32 |
public static function week() : self |
| 33 |
{ |
| 34 |
return self::getInstance('week'); |
| 35 |
} |
| 36 |
public static function month() : self |
| 37 |
{ |
| 38 |
return self::getInstance('month'); |
| 39 |
} |
| 40 |
public static function year() : self |
| 41 |
{ |
| 42 |
return self::getInstance('year'); |
| 43 |
} |
| 44 |
public function __toString() : string |
| 45 |
{ |
| 46 |
return $this->value; |
| 47 |
} |
| 48 |
private static function getInstance(string $value) : self |
| 49 |
{ |
| 50 |
if (!isset(self::$instances[$value])) { |
| 51 |
self::$instances[$value] = new self($value); |
| 52 |
} |
| 53 |
return self::$instances[$value]; |
| 54 |
} |
| 55 |
} |
| 56 |
|