vendor/sentry/sentry/src/SentrySdk.php line 44

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sentry;
  4. use Sentry\State\Hub;
  5. use Sentry\State\HubInterface;
  6. /**
  7.  * This class is the main entry point for all the most common SDK features.
  8.  *
  9.  * @author Stefano Arlandini <sarlandini@alice.it>
  10.  */
  11. final class SentrySdk
  12. {
  13.     /**
  14.      * @var HubInterface|null The current hub
  15.      */
  16.     private static $currentHub;
  17.     /**
  18.      * Constructor.
  19.      */
  20.     private function __construct()
  21.     {
  22.     }
  23.     /**
  24.      * Initializes the SDK by creating a new hub instance each time this method
  25.      * gets called.
  26.      */
  27.     public static function init(): HubInterface
  28.     {
  29.         self::$currentHub = new Hub();
  30.         return self::$currentHub;
  31.     }
  32.     /**
  33.      * Gets the current hub. If it's not initialized then creates a new instance
  34.      * and sets it as current hub.
  35.      */
  36.     public static function getCurrentHub(): HubInterface
  37.     {
  38.         if (null === self::$currentHub) {
  39.             self::$currentHub = new Hub();
  40.         }
  41.         return self::$currentHub;
  42.     }
  43.     /**
  44.      * Sets the current hub.
  45.      *
  46.      * @param HubInterface $hub The hub to set
  47.      */
  48.     public static function setCurrentHub(HubInterface $hub): HubInterface
  49.     {
  50.         self::$currentHub $hub;
  51.         return $hub;
  52.     }
  53. }