/** * @param string $nationalNumber * @param PhoneNumberDesc $numberDesc * @return bool */ public function isNumberPossibleForDesc($nationalNumber, PhoneNumberDesc $numberDesc) { $possibleNumberPatternMatcher = new Matcher($numberDesc->getPossibleNumberPattern(), $nationalNumber); return $possibleNumberPatternMatcher->matches(); }
/** * @param PhoneNumberDesc $other * @return PhoneNumberDesc */ public function mergeFrom(PhoneNumberDesc $other) { if ($other->hasNationalNumberPattern()) { $this->setNationalNumberPattern($other->getNationalNumberPattern()); } if ($other->hasPossibleNumberPattern()) { $this->setPossibleNumberPattern($other->getPossibleNumberPattern()); } if ($other->hasExampleNumber()) { $this->setExampleNumber($other->getExampleNumber()); } return $this; }
private function isNumberMatchingDesc($nationalNumber, PhoneNumberDesc $numberDesc) { $possibleNumberPatternMatcher = preg_match('/^(' . str_replace(array(PHP_EOL, ' '), '', $numberDesc->getPossibleNumberPattern()) . ')$/', $nationalNumber); $nationalNumberPatternMatcher = preg_match('/^(' . str_replace(array(PHP_EOL, ' '), '', $numberDesc->getNationalNumberPattern()) . ')$/', $nationalNumber); return $possibleNumberPatternMatcher && $nationalNumberPatternMatcher; }
private function isNumberMatchingDesc($nationalNumber, PhoneNumberDesc $numberDesc) { $possibleNumberPatternMatcher = preg_match('/^(' . $numberDesc->getPossibleNumberPattern() . ')$/x', $nationalNumber); $nationalNumberPatternMatcher = preg_match('/^' . $numberDesc->getNationalNumberPattern() . '$/x', $nationalNumber); return $possibleNumberPatternMatcher && $nationalNumberPatternMatcher; }
private function isNumberMatchingDesc($nationalNumber, PhoneNumberDesc $numberDesc) { if (DIRECTORY_SEPARATOR == '\\') { // For Windows $possibleNumberPatternMatcher = preg_match('/^(' . str_replace(array("\n", "\r", ' '), '', $numberDesc->getPossibleNumberPattern()) . ')$/', $nationalNumber); $nationalNumberPatternMatcher = preg_match('/^(' . str_replace(array("\n", "\r", ' '), '', $numberDesc->getNationalNumberPattern()) . ')$/', $nationalNumber); } else { // For Linux $possibleNumberPatternMatcher = preg_match('/^(' . str_replace(array(PHP_EOL, ' '), '', $numberDesc->getPossibleNumberPattern()) . ')$/', $nationalNumber); $nationalNumberPatternMatcher = preg_match('/^(' . str_replace(array(PHP_EOL, ' '), '', $numberDesc->getNationalNumberPattern()) . ')$/', $nationalNumber); } return $possibleNumberPatternMatcher && $nationalNumberPatternMatcher; }