libphonenumber\PhoneNumberToTimeZonesMapper::getInstance PHP Method

getInstance() public static method

The {@link PhoneNumberToTimeZonesMapper} is implemented as a singleton. Therefore, calling this method multiple times will only result in one instance being created.

public static getInstance ( $mappingDir = self::MAPPING_DATA_DIRECTORY ) : PhoneNumberToTimeZonesMapper
$mappingDir
return PhoneNumberToTimeZonesMapper instance
    public static function getInstance($mappingDir = self::MAPPING_DATA_DIRECTORY)
    {
        if (static::$instance === null) {
            static::$instance = new static($mappingDir);
        }
        return static::$instance;
    }

Usage Example

 public function testGBNumber()
 {
     $number = new PhoneNumber();
     $number->setCountryCode(44)->setNationalNumber(1614960000);
     $timeZone = PhoneNumberToTimeZonesMapper::getInstance();
     $this->assertEquals(array("Europe/London"), $timeZone->getTimeZonesForNumber($number));
 }
All Usage Examples Of libphonenumber\PhoneNumberToTimeZonesMapper::getInstance