| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
final class Unit 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 nanosecond() : self |
| 21 |
{ |
| 22 |
return self::getInstance('nanosecond'); |
| 23 |
} |
| 24 |
public static function microsecond() : self |
| 25 |
{ |
| 26 |
return self::getInstance('microsecond'); |
| 27 |
} |
| 28 |
public static function millisecond() : self |
| 29 |
{ |
| 30 |
return self::getInstance('millisecond'); |
| 31 |
} |
| 32 |
public static function second() : self |
| 33 |
{ |
| 34 |
return self::getInstance('second'); |
| 35 |
} |
| 36 |
public static function minute() : self |
| 37 |
{ |
| 38 |
return self::getInstance('minute'); |
| 39 |
} |
| 40 |
public static function hour() : self |
| 41 |
{ |
| 42 |
return self::getInstance('hour'); |
| 43 |
} |
| 44 |
public static function day() : self |
| 45 |
{ |
| 46 |
return self::getInstance('day'); |
| 47 |
} |
| 48 |
public static function week() : self |
| 49 |
{ |
| 50 |
return self::getInstance('week'); |
| 51 |
} |
| 52 |
public static function bit() : self |
| 53 |
{ |
| 54 |
return self::getInstance('bit'); |
| 55 |
} |
| 56 |
public static function byte() : self |
| 57 |
{ |
| 58 |
return self::getInstance('byte'); |
| 59 |
} |
| 60 |
public static function kilobyte() : self |
| 61 |
{ |
| 62 |
return self::getInstance('kilobyte'); |
| 63 |
} |
| 64 |
public static function kibibyte() : self |
| 65 |
{ |
| 66 |
return self::getInstance('kibibyte'); |
| 67 |
} |
| 68 |
public static function megabyte() : self |
| 69 |
{ |
| 70 |
return self::getInstance('megabyte'); |
| 71 |
} |
| 72 |
public static function mebibyte() : self |
| 73 |
{ |
| 74 |
return self::getInstance('mebibyte'); |
| 75 |
} |
| 76 |
public static function gigabyte() : self |
| 77 |
{ |
| 78 |
return self::getInstance('gigabyte'); |
| 79 |
} |
| 80 |
public static function gibibyte() : self |
| 81 |
{ |
| 82 |
return self::getInstance('gibibyte'); |
| 83 |
} |
| 84 |
public static function terabyte() : self |
| 85 |
{ |
| 86 |
return self::getInstance('terabyte'); |
| 87 |
} |
| 88 |
public static function tebibyte() : self |
| 89 |
{ |
| 90 |
return self::getInstance('tebibyte'); |
| 91 |
} |
| 92 |
public static function petabyte() : self |
| 93 |
{ |
| 94 |
return self::getInstance('petabyte'); |
| 95 |
} |
| 96 |
public static function pebibyte() : self |
| 97 |
{ |
| 98 |
return self::getInstance('pebibyte'); |
| 99 |
} |
| 100 |
public static function exabyte() : self |
| 101 |
{ |
| 102 |
return self::getInstance('exabyte'); |
| 103 |
} |
| 104 |
public static function exbibyte() : self |
| 105 |
{ |
| 106 |
return self::getInstance('exbibyte'); |
| 107 |
} |
| 108 |
public static function ratio() : self |
| 109 |
{ |
| 110 |
return self::getInstance('ratio'); |
| 111 |
} |
| 112 |
public static function percent() : self |
| 113 |
{ |
| 114 |
return self::getInstance('percent'); |
| 115 |
} |
| 116 |
/** |
| 117 |
* @deprecated `none` is not supported and will be removed in 5.x |
| 118 |
*/ |
| 119 |
public static function none() : self |
| 120 |
{ |
| 121 |
return self::getInstance('none'); |
| 122 |
} |
| 123 |
/** |
| 124 |
* @deprecated custom unit types are currently not supported. Will be removed in 5.x |
| 125 |
*/ |
| 126 |
public static function custom(string $unit) : self |
| 127 |
{ |
| 128 |
return new self($unit); |
| 129 |
} |
| 130 |
public function __toString() : string |
| 131 |
{ |
| 132 |
return $this->value; |
| 133 |
} |
| 134 |
private static function getInstance(string $value) : self |
| 135 |
{ |
| 136 |
if (!isset(self::$instances[$value])) { |
| 137 |
self::$instances[$value] = new self($value); |
| 138 |
} |
| 139 |
return self::$instances[$value]; |
| 140 |
} |
| 141 |
} |
| 142 |
|