PluginProbe
PayPlug for WooCommerce (Official) / 1.2.1
PayPlug for WooCommerce (Official) v1.2.1
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / lib / libphonenumber / RegexBasedMatcher.php

RegexBasedMatcher.php in PayPlug for WooCommerce (Official) 1.2.1, at lib/libphonenumber/RegexBasedMatcher.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace libphonenumber;
4
5 /**
6 * Class RegexBasedMatcher
7 * @package libphonenumber
8 * @internal
9 */
10 class RegexBasedMatcher implements MatcherAPIInterface
11 {
12 public static function create()
13 {
14 return new static();
15 }
16
17 /**
18 * Returns whether the given national number (a string containing only decimal digits) matches
19 * the national number pattern defined in the given {@code PhoneNumberDesc} message.
20 *
21 * @param string $number
22 * @param PhoneNumberDesc $numberDesc
23 * @param boolean $allowPrefixMatch
24 * @return boolean
25 */
26 public function matchNationalNumber($number, PhoneNumberDesc $numberDesc, $allowPrefixMatch)
27 {
28 $nationalNumberPattern = $numberDesc->getNationalNumberPattern();
29
30 // We don't want to consider it a prefix match when matching non-empty input against an empty
31 // pattern
32
33 if (strlen($nationalNumberPattern) === 0) {
34 return false;
35 }
36
37 return $this->match($number, $nationalNumberPattern, $allowPrefixMatch);
38 }
39
40 /**
41 * @param string $number
42 * @param string $pattern
43 * @param $allowPrefixMatch
44 * @return bool
45 */
46 private function match($number, $pattern, $allowPrefixMatch)
47 {
48 $matcher = new Matcher($pattern, $number);
49
50 if (!$matcher->lookingAt()) {
51 return false;
52 }
53
54 return $matcher->matches() ? true : $allowPrefixMatch;
55 }
56 }
57