| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry\Tracing; |
| 5 |
|
| 6 |
/** |
| 7 |
* This enum represents all the possible types of transaction sources. |
| 8 |
* |
| 9 |
* @see https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations |
| 10 |
*/ |
| 11 |
final class TransactionSource implements \Stringable |
| 12 |
{ |
| 13 |
/** |
| 14 |
* @var string The value of the enum instance |
| 15 |
*/ |
| 16 |
private $value; |
| 17 |
/** |
| 18 |
* @var array<string, self> A list of cached enum instances |
| 19 |
*/ |
| 20 |
private static $instances = []; |
| 21 |
private function __construct(string $value) |
| 22 |
{ |
| 23 |
$this->value = $value; |
| 24 |
} |
| 25 |
/** |
| 26 |
* User-defined name. |
| 27 |
*/ |
| 28 |
public static function custom() : self |
| 29 |
{ |
| 30 |
return self::getInstance('custom'); |
| 31 |
} |
| 32 |
/** |
| 33 |
* Raw URL, potentially containing identifiers. |
| 34 |
*/ |
| 35 |
public static function url() : self |
| 36 |
{ |
| 37 |
return self::getInstance('url'); |
| 38 |
} |
| 39 |
/** |
| 40 |
* Parametrized URL / route. |
| 41 |
*/ |
| 42 |
public static function route() : self |
| 43 |
{ |
| 44 |
return self::getInstance('route'); |
| 45 |
} |
| 46 |
/** |
| 47 |
* Name of the view handling the request. |
| 48 |
*/ |
| 49 |
public static function view() : self |
| 50 |
{ |
| 51 |
return self::getInstance('view'); |
| 52 |
} |
| 53 |
/** |
| 54 |
* Named after a software component, such as a function or class name. |
| 55 |
*/ |
| 56 |
public static function component() : self |
| 57 |
{ |
| 58 |
return self::getInstance('component'); |
| 59 |
} |
| 60 |
/** |
| 61 |
* Name of a background task (e.g. a Celery task). |
| 62 |
*/ |
| 63 |
public static function task() : self |
| 64 |
{ |
| 65 |
return self::getInstance('task'); |
| 66 |
} |
| 67 |
public function __toString() : string |
| 68 |
{ |
| 69 |
return $this->value; |
| 70 |
} |
| 71 |
private static function getInstance(string $value) : self |
| 72 |
{ |
| 73 |
if (!isset(self::$instances[$value])) { |
| 74 |
self::$instances[$value] = new self($value); |
| 75 |
} |
| 76 |
return self::$instances[$value]; |
| 77 |
} |
| 78 |
} |
| 79 |
|