For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in Canada, the expected cost returned by this method will be STANDARD_RATE, since the NANPA countries share the same country calling code.
Note: If the region from which the number is dialed is known, it is highly preferable to call {@link #getExpectedCostForRegion(PhoneNumber, String)} instead.
public getExpectedCost ( |
||
$number | the short number for which we want to know the expected cost category | |
Результат | integer | the highest expected cost category of the short number in the region(s) with the given country calling code |
public function testEmergencyNumberForSharedCountryCallingCode() { // Test the emergency number 112, which is valid in both Australia and the Christmas Islands. $this->assertTrue($this->shortInfo->isEmergencyNumber("112", RegionCode::AU)); $this->assertTrue($this->shortInfo->isValidShortNumberForRegion($this->parse("112", RegionCode::AU), RegionCode::AU)); $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCostForRegion($this->parse("112", RegionCode::AU), RegionCode::AU)); $this->assertTrue($this->shortInfo->isEmergencyNumber("112", RegionCode::CX)); $this->assertTrue($this->shortInfo->isValidShortNumberForRegion($this->parse("112", RegionCode::CX), RegionCode::CX)); $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCostForRegion($this->parse("112", RegionCode::CX), RegionCode::CX)); $sharedEmergencyNumber = new PhoneNumber(); $sharedEmergencyNumber->setCountryCode(61)->setNationalNumber(112); $this->assertTrue($this->shortInfo->isValidShortNumber($sharedEmergencyNumber)); $this->assertEquals(ShortNumberCost::TOLL_FREE, $this->shortInfo->getExpectedCost($sharedEmergencyNumber)); }