diff --git a/include/phone.au.inc b/include/phone.au.inc index f51efc5..72cede9 100644 --- a/include/phone.au.inc +++ b/include/phone.au.inc @@ -85,7 +85,7 @@ function valid_au_phone_number($phonenumber) { $rules[] = array("364", 9, 9); $rules[] = array("38", 9, 9); $rules[] = array("39", 9, 9); -// begin mobile phone numbers +// begin mobile phone numbers $rules[] = array("400", 9, 9); $rules[] = array("401", 9, 9); $rules[] = array("402", 9, 9); @@ -142,7 +142,7 @@ function valid_au_phone_number($phonenumber) { $rules[] = array("447", 9, 9); $rules[] = array("448", 9, 9); $rules[] = array("449", 9, 9); - $rules[] = array("449", 9, 9); + $rules[] = array("449", 9, 9); $rules[] = array("450 ", 9, 9); $rules[] = array("451", 9, 9); $rules[] = array("457", 9, 9); @@ -152,7 +152,7 @@ function valid_au_phone_number($phonenumber) { $rules[] = array("4592", 9, 9); $rules[] = array("466", 9, 9); $rules[] = array("488", 9, 9); -// end mobile phone numbers +// end mobile phone numbers $rules[] = array("50", 9, 9); $rules[] = array("51", 9, 9); $rules[] = array("52", 9, 9); @@ -202,7 +202,7 @@ function valid_au_phone_number($phonenumber) { $rules[] = array("899", 9, 9); foreach ($rules as $rule) { - if (preg_match('/^'.$rule[0].'/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) { + if (preg_match('/^' . $rule[0] . '/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) { return TRUE; } } @@ -233,7 +233,7 @@ function format_au_phone_number($phonenumber, $field = FALSE) { * strip and save the extension (x9999) postfix if found */ if (preg_match('/(x[0-9]+)$/', $phonenumber, $match)) { - $extension = ' ('.$match[1].')'; + $extension = ' (' . $match[1] . ')'; $phonenumber = preg_replace('/x[0-9]+$/', '', $phonenumber); } @@ -280,4 +280,3 @@ function format_au_phone_number($phonenumber, $field = FALSE) { // default return $prefix . $phonenumber . $extension; } - diff --git a/include/phone.be.inc b/include/phone.be.inc index 97cb402..9dfa73c 100644 --- a/include/phone.be.inc +++ b/include/phone.be.inc @@ -23,7 +23,7 @@ function valid_be_phone_number($phonenumber) { $regex = "/^(\+32|0)[1-9]\d{7,8}$/i"; - $phonenumber = str_replace(array(' ','-','(',')'), '', $phonenumber); + $phonenumber = str_replace(array(' ', '-', '(', ')'), '', $phonenumber); // return true if valid, false otherwise return (bool) preg_match($regex, $phonenumber); } @@ -40,9 +40,9 @@ function format_be_phone_number($phonenumber, $field) { if ($field['phone_country_code']) { if ($matches[1] != "+32") { - $phonenumber = "+32" . " " . $phonenumber; + $phonenumber = "+32" . " " . $phonenumber; } } - + return $phonenumber; } diff --git a/include/phone.br.inc b/include/phone.br.inc index 90074eb..2de9195 100644 --- a/include/phone.br.inc +++ b/include/phone.br.inc @@ -35,7 +35,7 @@ function valid_br_phone_number($phonenumber) { * @return string Returns a string containting the phone number with some formatting. */ function format_br_phone_number($phonenumber, $field = FALSE) { - $phone = str_replace(array(' ','-','(',')'), '', $phonenumber); + $phone = str_replace(array(' ', '-', '(', ')'), '', $phonenumber); if (preg_match(PHONE_BR_REGEX, $phone, $matches) != 1) { return $phonenumber; // this is possible? } diff --git a/include/phone.ca.inc b/include/phone.ca.inc index 6fa1432..d8c803b 100644 --- a/include/phone.ca.inc +++ b/include/phone.ca.inc @@ -78,13 +78,13 @@ function format_ca_phone_number($phonenumber, $field) { // Optional extension if ($matches[5] != '') { - $phonenumber .= ' x' . $matches[5]; + $phonenumber .= ' x' . $matches[5]; } if ($field['phone_country_code']) { - // This condition check is pointless. + // This condition check is pointless. if ($matches[1] != '1') { - $phonenumber = '1' . ' ' . $phonenumber; + $phonenumber = '1' . ' ' . $phonenumber; } } return $phonenumber; diff --git a/include/phone.ch.inc b/include/phone.ch.inc index 512533b..86934bf 100644 --- a/include/phone.ch.inc +++ b/include/phone.ch.inc @@ -23,7 +23,7 @@ function phone_ch_metadata() { * @return boolean Returns boolean FALSE if the phone number is not valid. */ function valid_ch_phone_number($phonenumber) { - $phonenumber = str_replace(array(' ','-','.','/','(',')'), '', $phonenumber); + $phonenumber = str_replace(array(' ', '-', '.', '/', '(', ')'), '', $phonenumber); $match =array(); $result = (bool) preg_match(PHONE_CH_REGEX, $phonenumber, $match); return $result; @@ -36,16 +36,16 @@ function valid_ch_phone_number($phonenumber) { * @return string Returns a string containting the phone number with some formatting. */ function format_ch_phone_number($phonenumber, $field = FALSE) { - $phone = str_replace(array(' ','-','.','/','(',')'), '', $phonenumber); + $phone = str_replace(array(' ', '-', '.', '/', '(', ')'), '', $phonenumber); $matches =array(); if (preg_match(PHONE_CH_REGEX, $phone, $matches) != 1) { return $phonenumber; // not a switzerland phone number } $value =($field && $field['phone_country_code'] ? '+41 (0)' : '0') . - substr($matches[2],0,2). - ' '.substr($matches[2],2,3). - ' '.substr($matches[2],5,2). - ' '.substr($matches[2],7); + substr($matches[2], 0, 2) . + ' ' . substr($matches[2], 2, 3) . + ' ' . substr($matches[2], 5, 2) . + ' ' . substr($matches[2], 7); return $value; } diff --git a/include/phone.cl.inc b/include/phone.cl.inc index 400b556..c7e6adb 100644 --- a/include/phone.cl.inc +++ b/include/phone.cl.inc @@ -41,7 +41,7 @@ function format_cl_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.cr.inc b/include/phone.cr.inc index d2d6a8b..6b49ce2 100644 --- a/include/phone.cr.inc +++ b/include/phone.cr.inc @@ -39,12 +39,12 @@ function valid_cr_phone_number($phonenumber) { /* Accepts: +506 88798857 - +506 88-79-88-57 + +506 88-79-88-57 00506 88798857 00506 88-79-88-57 Rejects: +506 8 8798857 - +506 8 8-79-88-57 + +506 8 8-79-88-57 00506 8 8798857 00506 8 8-79-88-57 */ @@ -62,11 +62,11 @@ function format_cr_phone_number($phonenumber, $field = FALSE) { //dprint_r($matches); $phonenumber = $matches[4] . '-' . $matches[5] . '-' . $matches[6] . '-' . $matches[7]; - if($matches[2]){ - if($matches[1]) - $phonenumber = "+" . $matches[2] . " " . $phonenumber; - else - $phonenumber = $matches[2] . " " . $phonenumber; + if ($matches[2]) { + if ($matches[1]) + $phonenumber = "+" . $matches[2] . " " . $phonenumber; + else + $phonenumber = $matches[2] . " " . $phonenumber; } return $phonenumber; diff --git a/include/phone.cs.inc b/include/phone.cs.inc index 2b1c3a6..52c1c7a 100644 --- a/include/phone.cs.inc +++ b/include/phone.cs.inc @@ -44,10 +44,10 @@ function format_cs_phone_number($phonenumber, $field) { preg_match($regex, $phonenumber, $matches); if ($field['phone_country_code']) { - $phonenumber = '+420' . ' ' . $matches[2] .' '. $matches[3] .' '. $matches[4]; + $phonenumber = '+420' . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4]; } else { - $phonenumber = $matches[2] .' '. $matches[3] .' '. $matches[4]; + $phonenumber = $matches[2] . ' ' . $matches[3] . ' ' . $matches[4]; } return $phonenumber; diff --git a/include/phone.eg.inc b/include/phone.eg.inc index b12b942..6211820 100644 --- a/include/phone.eg.inc +++ b/include/phone.eg.inc @@ -1,67 +1,73 @@ = $rule[1] && strlen($phonenumber) <= $rule[2]) { + if (preg_match('/^' . $rule[0] . '/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) { return TRUE; } } @@ -94,14 +94,14 @@ function format_il_phone_number($phonenumber) { if (preg_match('/^([0-9]{4})([0-9]{3})([0-9]{3})$/', $phonenumber, $match)) { return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension; } - + /* * cell phone * Eg. 054 9999 999 */ if (preg_match('/^([0-9]{3})([0-9]{4})([0-9]{3})$/', $phonenumber, $match)) { return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension; - } + } // default return $prefix . $phonenumber . $extension; diff --git a/include/phone.int.inc b/include/phone.int.inc index 68db303..d45cfa9 100644 --- a/include/phone.int.inc +++ b/include/phone.int.inc @@ -1,5 +1,8 @@ 'ca', '1' => 'us', '7' => 'ru', @@ -158,7 +161,7 @@ function phone_country_code_convert($code, $input_type = 'digits') { '46' => 'se', '47' => 'no', '48' => 'pl', - '49' => 'de', + '49' => 'de', '51' => 'pe', '52' => 'mx', '53' => 'cu', @@ -166,7 +169,7 @@ function phone_country_code_convert($code, $input_type = 'digits') { '55' => 'br', '56' => 'cl', '57' => 'co', - '58' => 've', + '58' => 've', '60' => 'my', '61' => 'au', '61' => 'cc', @@ -186,7 +189,7 @@ function phone_country_code_convert($code, $input_type = 'digits') { '93' => 'af', '94' => 'lk', '95' => 'mm', - '98' => 'ir', + '98' => 'ir', '212' => 'ma', '213' => 'dz', '216' => 'tn', @@ -269,7 +272,7 @@ function phone_country_code_convert($code, $input_type = 'digits') { '385' => 'hr', '386' => 'si', '387' => 'ba', - '389' => 'mk', + '389' => 'mk', '420' => 'cz', '421' => 'sk', '423' => 'li', @@ -312,14 +315,14 @@ function phone_country_code_convert($code, $input_type = 'digits') { '689' => 'pf', '690' => 'tk', '691' => 'fm', - '692' => 'mh', + '692' => 'mh', '850' => 'kp', '852' => 'hk', '853' => 'mo', '855' => 'kh', '856' => 'la', '880' => 'bd', - '886' => 'tw', + '886' => 'tw', '960' => 'mv', '961' => 'lb', '962' => 'jo', @@ -342,7 +345,7 @@ function phone_country_code_convert($code, $input_type = 'digits') { '994' => 'az', '995' => 'ge', '996' => 'kg', - '998' => 'uz', + '998' => 'uz', ); } @@ -351,4 +354,3 @@ function phone_country_code_convert($code, $input_type = 'digits') { } return isset($codes[$code]) ? $codes[$code] : FALSE; } - diff --git a/include/phone.it.inc b/include/phone.it.inc index 3906829..a2aee89 100644 --- a/include/phone.it.inc +++ b/include/phone.it.inc @@ -41,7 +41,7 @@ function format_it_phone_number($phonenumber, $field) { if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } diff --git a/include/phone.jo.inc b/include/phone.jo.inc index 72f5b28..c3b8d03 100644 --- a/include/phone.jo.inc +++ b/include/phone.jo.inc @@ -7,7 +7,7 @@ * CCK Field for Jordanian phone numbers. */ -function phone_jo_metadata(){ +function phone_jo_metadata() { // These strings are translated using t() on output. return array( 'error' => '"%value" is not a valid Jordanian phone number, Please check the spaces and dashes in your number.', @@ -20,7 +20,7 @@ function phone_jo_metadata(){ * @param string $phonenumber * @return boolean Returns boolean FALSE if the phone number is not valid. */ -function valid_jo_phone_number($phonenumber){ +function valid_jo_phone_number($phonenumber) { /** Accepts: @@ -86,7 +86,7 @@ function valid_jo_phone_number($phonenumber){ * @param string $phonenumber * @return string Returns a string containting the phone number with some formatting. */ -function format_jo_phone_number($phonenumber, $field = FALSE){ +function format_jo_phone_number($phonenumber, $field = FALSE) { $phonenumber = trim($phonenumber); @@ -96,6 +96,6 @@ function format_jo_phone_number($phonenumber, $field = FALSE){ $phonenumber = preg_replace('/^(\+962|00962|962|0)|[-\s]/', '', $matches[0]); - return '+962'.$phonenumber; + return '+962' . $phonenumber; } diff --git a/include/phone.nl.inc b/include/phone.nl.inc index 781790f..1bef8eb 100644 --- a/include/phone.nl.inc +++ b/include/phone.nl.inc @@ -26,25 +26,25 @@ function valid_nl_phone_number($phonenumber) { /* Accepts: - 06-12345678 - 06 123 456 78 - 010-1234567 - 020 123 4567 - 0221-123456 - 0221 123 456 + 06-12345678 + 06 123 456 78 + 010-1234567 + 020 123 4567 + 0221-123456 + 0221 123 456 Rejects: - 05-12345678 - 123-4567890 - 123 456 7890 + 05-12345678 + 123-4567890 + 123 456 7890 */ // define regular expression $regex = '/ - ([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber + ([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber | - ([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code + ([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code | - ([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code + ([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code /x'; // return true if valid, false otherwise @@ -75,12 +75,12 @@ function format_nl_phone_number($phonenumber, $field) { $areacode = $matches[1]; $localnumber = preg_replace('/ /', '', $matches[2]); - $phonenumber = $areacode. '-'. $localnumber; + $phonenumber = $areacode . '-' . $localnumber; // Add Country code if needed if ($field['phone_country_code']) { $areacode = preg_replace('/^0/', '', $areacode); - $phonenumber = '+31-'. $areacode. '-'. $localnumber; + $phonenumber = '+31-' . $areacode . '-' . $localnumber; } return $phonenumber; diff --git a/include/phone.nz.inc b/include/phone.nz.inc index 9f6da26..2383e1e 100644 --- a/include/phone.nz.inc +++ b/include/phone.nz.inc @@ -111,11 +111,11 @@ function valid_nz_phone_number($phonenumber) { $rules[] = array('99', 8, 8); foreach ($rules as $rule) { - if (preg_match('/^'.$rule[0].'/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) { - return true; + if (preg_match('/^' . $rule[0] . '/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) { + return TRUE; } } - return false; + return FALSE; } /** @@ -152,7 +152,7 @@ function format_nz_phone_number($phonenumber, $field) { * strip and save the extension (x9999) postfix if found */ if (preg_match('/(x[0-9]+)$/', $phonenumber, $match)) { - $extension = ' '.$match[1]; + $extension = ' ' . $match[1]; $phonenumber = preg_replace('/x[0-9]+$/', '', $phonenumber); } @@ -193,13 +193,13 @@ function format_nz_phone_number($phonenumber, $field) { */ if (preg_match('/^(900|800)(\d+)$/', $phonenumber, $match)) { // How we format depends on the length - $formatted = null; - switch(strlen($match[2])) { + $formatted = NULL; + switch (strlen($match[2])) { case 5: $formatted = preg_replace('/^(\d{2})(\d{3})$/', '$1$2', $match[2]); break; case 6: $formatted = preg_replace('/^(\d{3})(\d{3})$/', '$1$2', $match[2]); break; case 7: $formatted = preg_replace('/^(\d{3})(\d{4})$/', '$1 $2', $match[2]); break; } - return _format_nz_phone_number_prefix($prefix, $match[1]).$formatted; + return _format_nz_phone_number_prefix($prefix, $match[1]) . $formatted; } // default (probably bad) @@ -216,9 +216,9 @@ function format_nz_phone_number($phonenumber, $field) { function _format_nz_phone_number_prefix($prefix, $area_code) { $area_code = intval($area_code); if (in_array($area_code, array('800', '900'))) { - return ($prefix == '0') ? $prefix.$area_code.' ' : $prefix.' '.$area_code.' '; + return ($prefix == '0') ? $prefix . $area_code . ' ' : $prefix . ' ' . $area_code . ' '; } else { - return ($prefix == '0') ? '('.$prefix.$area_code.') ' : $prefix.' '.$area_code.' '; + return ($prefix == '0') ? '(' . $prefix . $area_code . ') ' : $prefix . ' ' . $area_code . ' '; } } diff --git a/include/phone.ph.inc b/include/phone.ph.inc index c1fa2fe..04a685f 100644 --- a/include/phone.ph.inc +++ b/include/phone.ph.inc @@ -8,7 +8,7 @@ function phone_ph_metadata() { // These strings are translated using t() on output. return array( - 'error' => '"%value" is not a valid Philippine phone number
Example of valid Philippine phone numbers: +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567', + 'error' => '"%value" is not a valid Philippine phone number
Example of valid Philippine phone numbers: +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567', ); } @@ -24,9 +24,9 @@ function valid_ph_phone_number($phonenumber) { /* Accepts: +63197071234567 - +63197071234567 + +63197071234567 +63(19707) 1234567 - +63(19707) 123-4567 + +63(19707) 123-4567 +63 19707 123 4567 +63 19707 123-4567 (19707) 1234567 loc. 1234 @@ -47,16 +47,15 @@ function valid_ph_phone_number($phonenumber) { /x"; // return true if valid, false otherwise if (!preg_match($regex, $phonenumber)) { - return FALSE; + return FALSE; } - else - { - return TRUE; + else { + return TRUE; } } /** - * Convert a valid Philippine phone number into standard +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567 + * Convert a valid Philippine phone number into standard +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567 * * @param $phonenumber must be a valid ten-digit number (with optional extension) * @@ -66,9 +65,9 @@ function format_ph_phone_number($phonenumber, $field = FALSE) { $area = $number = $extension = $description = ''; //Simplify to 10 digit number and clean up ready for international reformat. - $phonenumber = preg_replace("/^\+63/","",$phonenumber); - $phonenumber = preg_replace("/\(/","",$phonenumber); - $phonenumber = preg_replace("/\)/","",$phonenumber); + $phonenumber = preg_replace("/^\+63/", "", $phonenumber); + $phonenumber = preg_replace("/\(/", "", $phonenumber); + $phonenumber = preg_replace("/\)/", "", $phonenumber); //If there are some spaces in the number assume some level of preformatting $regex = "/ @@ -111,17 +110,17 @@ function format_ph_phone_number($phonenumber, $field = FALSE) { # capture the optional extension number (\s*loc\.\s*|\s*ext\.\s*)? (\d*)? - ([a-zA-Z0-9\-\. \/\,\']{0,})? + ([a-zA-Z0-9\-\. \/\,\']{0,})? /x"; preg_match($regex, $phonenumber, $matches); $area = $matches[2] . $matches[7] . $matches[12] . $matches[17] . $matches[22]; $number = $matches[4] . $matches[9] . $matches[14] . $matches[19] . $matches[24] . '-' . $matches[6] . $matches[11] . $matches[16] . $matches[21] . $matches[26]; $extension = $matches[28]; - $description = $matches[29]; + $description = $matches[29]; $phonenumber = '+63 (' . $area . ') ' . $number; $phonenumber .= (empty($extension)) ? '' : " loc. $extension"; - $phonenumber .= (empty($description))? '' : " $description"; + $phonenumber .= (empty($description))? '' : " $description"; return $phonenumber; } diff --git a/include/phone.pk.inc b/include/phone.pk.inc index 2cc10d6..0d1171a 100644 --- a/include/phone.pk.inc +++ b/include/phone.pk.inc @@ -41,7 +41,7 @@ function format_pk_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.pl.inc b/include/phone.pl.inc index 70354ec..25b04d9 100644 --- a/include/phone.pl.inc +++ b/include/phone.pl.inc @@ -41,7 +41,7 @@ function format_pl_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.ru.inc b/include/phone.ru.inc index 529a4c8..60aaa61 100644 --- a/include/phone.ru.inc +++ b/include/phone.ru.inc @@ -54,9 +54,9 @@ function format_ru_phone_number($phonenumber, $field = FALSE) { ^\D* # ignore non-digits ([78])? # an optional 78 \D* # optional separator - (\d{3,5}) # area code 3-5 digit + (\d{3,5}) # area code 3-5 digit \D* # optional separator - (\d{1,3}) # capture 3-digit prefix + (\d{1,3}) # capture 3-digit prefix \D* # optional separator (\d{2}) # 2-digit line number \D* # optional separator diff --git a/include/phone.se.inc b/include/phone.se.inc index b13a9c6..832eed9 100644 --- a/include/phone.se.inc +++ b/include/phone.se.inc @@ -41,7 +41,7 @@ function format_se_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.sg.inc b/include/phone.sg.inc index 6b4b9f7..5605ab9 100644 --- a/include/phone.sg.inc +++ b/include/phone.sg.inc @@ -51,7 +51,7 @@ function format_sg_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.ua.inc b/include/phone.ua.inc index 66208d2..2ec8a8c 100644 --- a/include/phone.ua.inc +++ b/include/phone.ua.inc @@ -19,7 +19,7 @@ function _phone_ua_get_valid_masks() { $result = cache_get('phone' . __FUNCTION__); - if( !empty($result) ) { + if (!empty($result)) { return $result->data; } @@ -550,12 +550,12 @@ function valid_ua_phone_number($phonenumber) { // Please note - pure 8 as a prefix is obsolete. $regex = "/^(\+38)?0(" . $codes . ")$/"; if (preg_match($regex, $refined_phonenumber)) { - return true; + return TRUE; } } // return true if valid, false otherwise - return false; + return FALSE; } /** @@ -573,7 +573,7 @@ function format_ua_phone_number($phonenumber, $field) { /* ==> to be done ==> add the country code if ($field['phone_country_code']) { if ($matches[1] != "+39") { - $phonenumber = "+39" . " " . $phonenumber; + $phonenumber = "+39" . " " . $phonenumber; } } */ diff --git a/include/phone.za.inc b/include/phone.za.inc index 304ee78..7202cd6 100644 --- a/include/phone.za.inc +++ b/include/phone.za.inc @@ -24,7 +24,7 @@ function valid_za_phone_number($phonenumber) { // define regular expression $regex = '/^((?:\+27|27)|0)[ ]*((\d{2})(-| )?(\d{3})(-| )?(\d{4})|(\d{2})( |-)(\d{7}))$/'; - + // return true if valid, false otherwise return (bool) preg_match($regex, $phonenumber); } @@ -42,7 +42,7 @@ function format_za_phone_number($phonenumber, $field) { // get digits of phone number preg_match($regex, $phonenumber, $matches); - + /* drupal_set_message('$matches[1] = ' . $matches[1], 'error'); drupal_set_message('$matches[2] = ' . $matches[2], 'error'); @@ -55,10 +55,10 @@ function format_za_phone_number($phonenumber, $field) { */ if ($field['phone_country_code']) { - $phonenumber = '+27' . ' ' . $matches[3] .'-'. $matches[5] .'-'. $matches[7]; + $phonenumber = '+27' . ' ' . $matches[3] . '-' . $matches[5] . '-' . $matches[7]; } else { - $phonenumber = $matches[3] .'-'. $matches[5] .'-'. $matches[7]; + $phonenumber = $matches[3] . '-' . $matches[5] . '-' . $matches[7]; } return $phonenumber; diff --git a/phone.module b/phone.module index 9979c2d..ed53c0b 100644 --- a/phone.module +++ b/phone.module @@ -91,7 +91,7 @@ function phone_field_settings_form($field, $instance, $has_data) { '#type' => 'select', '#title' => t('Country'), '#options' => phone_countries(), - '#default_value' => isset ($settings['country']) ? $settings['country'] : NULL, + '#default_value' => isset($settings['country']) ? $settings['country'] : NULL, '#description' => t('Which country-specific rules should this field be validated against and formatted according to.'), '#disabled' => $has_data, '#required' => TRUE, @@ -291,7 +291,7 @@ function phone_token_values($type, $object = NULL, $options = array()) { * Implementation of hook_simpletest(). */ function phone_simpletest() { - $dir = drupal_get_path('module', 'phone'). '/tests'; + $dir = drupal_get_path('module', 'phone') . '/tests'; $tests = file_scan_directory($dir, '\.test$'); return array_keys($tests); } @@ -313,7 +313,7 @@ function phone_supported_countrycode($countrycode) { /** - * Get a country meta info + * Get a country meta info. * * @param string $countrycode * @return array Returns a array containing country metadata @@ -324,8 +324,8 @@ function phone_country_info($countrycode = NULL) { $countrycode = trim($countrycode); if (phone_countries($countrycode) !== FALSE) { - $phone_info_function = 'phone_'. $countrycode . '_metadata'; - module_load_include('inc', 'phone', 'include/phone.'. $countrycode); + $phone_info_function = 'phone_' . $countrycode . '_metadata'; + module_load_include('inc', 'phone', 'include/phone.' . $countrycode); if (function_exists($phone_info_function)) { return $phone_info_function(); @@ -348,8 +348,8 @@ function valid_phone_number($countrycode, $phonenumber) { $phonenumber = trim($phonenumber); if (phone_supported_countrycode($countrycode)) { - $valid_phone_function = 'valid_'. $countrycode . '_phone_number'; - module_load_include('inc', 'phone', 'include/phone.'. $countrycode); + $valid_phone_function = 'valid_' . $countrycode . '_phone_number'; + module_load_include('inc', 'phone', 'include/phone.' . $countrycode); if (function_exists($valid_phone_function)) { return $valid_phone_function($phonenumber); @@ -372,8 +372,8 @@ function format_phone_number($countrycode, $phonenumber, $field) { $phonenumber = trim($phonenumber); if (phone_supported_countrycode($countrycode)) { - $format_phone_function = 'format_'. $countrycode . '_phone_number'; - module_load_include('inc', 'phone', 'include/phone.'. $countrycode); + $format_phone_function = 'format_' . $countrycode . '_phone_number'; + module_load_include('inc', 'phone', 'include/phone.' . $countrycode); if (function_exists($format_phone_function)) { return $format_phone_function($phonenumber, $field); @@ -382,4 +382,3 @@ function format_phone_number($countrycode, $phonenumber, $field) { //Country not taken into account yet return FALSE; } - diff --git a/tests/phone.au.test b/tests/phone.au.test index 67e9c9d..96bc87b 100644 --- a/tests/phone.au.test +++ b/tests/phone.au.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('au', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('au', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.be.test b/tests/phone.be.test index 6943ff0..4b3b88e 100644 --- a/tests/phone.be.test +++ b/tests/phone.be.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('be', '023456789'), '"023456789" should be valid'); $this->assertTrue(valid_phone_number('be', '0478990011'), '"0478990011" should be valid'); $this->assertTrue(valid_phone_number('be', '01 234 56 78'), '"01 234 56 78" should be valid'); - $this->assertTrue(valid_phone_number('be', '+32 12345678'), '"+32 12345678" should be valid'); + $this->assertTrue(valid_phone_number('be', '+32 12345678'), '"+32 12345678" should be valid'); } public function testPhoneBEInvalid() { @@ -26,6 +31,6 @@ class BEPhoneNumberTestCase extends DrupalWebTestCase { } public function testPhoneBEFormatting() { - //$this->assertEqual(format_phone_number('be', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('be', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.br.test b/tests/phone.br.test index 2573b67..28f9879 100644 --- a/tests/phone.br.test +++ b/tests/phone.br.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('br', '1234-5678 '), t('Test valid - 1234-5678')); $this->assertTrue(valid_phone_number('br', '12345678'), t('Test valid - 12345678')); $this->assertTrue(valid_phone_number('br', '+55 11 2222-3333'), t('Test valid - +55 11 2222-3333')); - + $this->assertTrue(valid_phone_number('br', '011 5555-1234'), t('Test valid - 011 5555-1234')); $this->assertTrue(valid_phone_number('br', '(011) 5555 1234'), t('Test valid - (011) 5555 1234')); $this->assertTrue(valid_phone_number('br', '(11) 5555.1234'), t('Test valid - (11) 5555.1234')); @@ -34,6 +39,6 @@ class BRPhoneNumberTestCase extends DrupalWebTestCase { } public function testPhoneBRFormatting() { - $this->assertEqual(format_br_phone_number('+55 11 2222-3333', null), '+55 (11) 222-333', t('Brazil - +55 (11) 222-333')); + $this->assertEqual(format_br_phone_number('+55 11 2222-3333', NULL), '+55 (11) 222-333', t('Brazil - +55 (11) 222-333')); } -} \ No newline at end of file +} diff --git a/tests/phone.ca.test b/tests/phone.ca.test index bf6477c..bdf28b3 100644 --- a/tests/phone.ca.test +++ b/tests/phone.ca.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('ca', '800-555-1212'), t('Test valid - 800-555-1212')); $this->assertTrue(valid_phone_number('ca', '(201)223-4567'), t('Test valid - (201)223-4567')); $this->assertTrue(valid_phone_number('ca', '604 543 9245'), t('Test valid - British Columbia 604 543 9245')); - + } public function testPhoneCAInvalid() { - //$this->assertFalse(valid_phone_number('ca', '021 3012 3456'), t('Test invalid ')); + //$this->assertFalse(valid_phone_number('ca', '021 3012 3456'), t('Test invalid')); } public function testPhoneCAFormatting() { - //$this->assertEqual(format_phone_number('ca', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('ca', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.ch.test b/tests/phone.ch.test index 98dcd3c..c7973b9 100644 --- a/tests/phone.ch.test +++ b/tests/phone.ch.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('ch', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('ch', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.cl.test b/tests/phone.cl.test index 92a13d9..5a9279f 100644 --- a/tests/phone.cl.test +++ b/tests/phone.cl.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('cl', '0412459848'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('cl', '063421232'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('cl', '0412459848'), t('Test invalid')); + $this->assertFalse(valid_phone_number('cl', '063421232'), t('Test invalid')); } public function testPhoneCLFormatting() { - //$this->assertEqual(format_phone_number('cl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('cl', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.cn.test b/tests/phone.cn.test index 0286020..572a8c3 100644 --- a/tests/phone.cn.test +++ b/tests/phone.cn.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('cn', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('cn', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.cr.test b/tests/phone.cr.test index 0f2a97e..96cfc13 100644 --- a/tests/phone.cr.test +++ b/tests/phone.cr.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('cr', '021 3012 3456'), t('Test invalid ')); + //$this->assertFalse(valid_phone_number('cr', '021 3012 3456'), t('Test invalid')); } public function testPhoneCRFormatting() { - //$this->assertEqual(format_phone_number('cr', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('cr', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.cs.test b/tests/phone.cs.test index 99abc92..ecd4166 100644 --- a/tests/phone.cs.test +++ b/tests/phone.cs.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('cs', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('cs', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.eg.test b/tests/phone.eg.test index 9fb3631..81e9833 100644 --- a/tests/phone.eg.test +++ b/tests/phone.eg.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('eg', '021 3012 3456'), t('Test invalid ')); + //$this->assertFalse(valid_phone_number('eg', '021 3012 3456'), t('Test invalid')); } public function testPhoneEGFormatting() { - //$this->assertEqual(format_phone_number('eg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('eg', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.es.test b/tests/phone.es.test index e5394eb..f1ec6a5 100644 --- a/tests/phone.es.test +++ b/tests/phone.es.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('es', '9988-989898'), t('Test invalid - 9988-989898')); $this->assertFalse(valid_phone_number('es', '989898988989'), t('Test invalid - 989898988989')); - $this->assertFalse(valid_phone_number('es', '9 9898989898'), t('Test invalid - 9 9898989898')); + $this->assertFalse(valid_phone_number('es', '9 9898989898'), t('Test invalid - 9 9898989898')); } public function testPhoneESFormatting() { - //$this->assertEqual(format_phone_number('es', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('es', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } } - diff --git a/tests/phone.fr.test b/tests/phone.fr.test index 4524ccd..0cb94fc 100644 --- a/tests/phone.fr.test +++ b/tests/phone.fr.test @@ -1,5 +1,10 @@ t('France Phone number test'), - 'description' => t('Executes test suite for validating / formatting France phone number.'), - 'group' => t('Phone') + 'name' => t('France Phone number test'), + 'description' => t('Executes test suite for validating / formatting France phone number.'), + 'group' => t('Phone') ); } function setUp() { parent::setUp(); - include_once('./'. drupal_get_path('module', 'phone') .'/phone.fr.inc'); + include_once('./' . drupal_get_path('module', 'phone') . '/phone.fr.inc'); } - + public function testPhoneFRValid() { // test cleaning phone number $this->assertTrue(valid_phone_number('fr', ' +33 123 45 - (67) 89'), "' +33 123 45 - (67) 89' should be valid"); - + $this->assertTrue(valid_phone_number('fr', '+33123456789'), "'+33123456789' should be valid"); $this->assertTrue(valid_phone_number('fr', '0123456789'), "'0123456789' should be valid"); @@ -54,8 +59,8 @@ class PhoneFrenchTest extends DrupalWebTestCase { // 087... // 870... 871... 872... 873... 874... 875... 877... 878... 879... assigned foreach (array('870', '871', '872', '873', '874', '875', '877', '878', '879') as $za) { - $this->assertTrue(valid_phone_number('fr', '+33'. $za .'123456'), "'+33 $za 1234567' is be valid"); - $this->assertTrue(valid_phone_number('fr', '0'. $za .'123456'), "'0 $za 1234567' is be valid"); + $this->assertTrue(valid_phone_number('fr', '+33' . $za . '123456'), "'+33 $za 1234567' is be valid"); + $this->assertTrue(valid_phone_number('fr', '0' . $za . '123456'), "'0 $za 1234567' is be valid"); } } @@ -86,8 +91,8 @@ class PhoneFrenchTest extends DrupalWebTestCase { // 80... 81... 82... 83... 84... 86... 88... 89... not assigned foreach (array('80', '81', '82', '83', '84', '86', '88', '89') as $za) { - $this->assertFalse(valid_phone_number('fr', '+33'. $za .'1234567'), "'+33'. $za .'1234567' is unassigned so should not be valid"); - $this->assertFalse(valid_phone_number('fr', '0'. $za .'1234567'), "'0'. $za .'1234567' is unassigned so should not be valid"); + $this->assertFalse(valid_phone_number('fr', '+33' . $za . '1234567'), "'+33' . $za . '1234567' is unassigned so should not be valid"); + $this->assertFalse(valid_phone_number('fr', '0' . $za . '1234567'), "'0' . $za . '1234567' is unassigned so should not be valid"); } // 09... not assigned @@ -108,8 +113,8 @@ class PhoneFrenchTest extends DrupalWebTestCase { $this->assertEqual(format_fr_phone_number('+33 123456789'), '0123456789', "international --> national"); $this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89'), '0123456789', "international --> national"); - $add_country_code = array('phone_country_code'=> TRUE); + $add_country_code = array('phone_country_code' => TRUE); $this->assertEqual(format_fr_phone_number('+33 123456789', $add_country_code), '+33 123456789', "international --> international"); $this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89', $add_country_code), '+33 123456789', "international --> international"); } -} \ No newline at end of file +} diff --git a/tests/phone.hu.test b/tests/phone.hu.test index 0878e0b..571eb3c 100644 --- a/tests/phone.hu.test +++ b/tests/phone.hu.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('hu', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('hu', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.il.test b/tests/phone.il.test index a5e763a..d326d35 100644 --- a/tests/phone.il.test +++ b/tests/phone.il.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('il', '1800 999 999'), '"1800 999 999" should be valid'); + $this->assertTrue(valid_phone_number('il', '1800 999 999'), '"1800 999 999" should be valid'); } public function testPhoneILInvalid() { @@ -22,6 +27,6 @@ class ILPhoneNumberTestCase extends DrupalWebTestCase { } public function testPhoneILFormatting() { - $this->assertEqual(format_phone_number('il', '1800 999 999', null), '1800 999 999', 'Formatting OK "1800 999 999" --> "1800 999 999"'); + $this->assertEqual(format_phone_number('il', '1800 999 999', NULL), '1800 999 999', 'Formatting OK "1800 999 999" --> "1800 999 999"'); } -} \ No newline at end of file +} diff --git a/tests/phone.int.test b/tests/phone.int.test index 219c297..063d512 100644 --- a/tests/phone.int.test +++ b/tests/phone.int.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('it', '02a343536'), t('Test invalid - 02a343536')); $this->assertFalse(valid_phone_number('it', '02+343536'), t('Test invalid - 02+343536')); $this->assertFalse(valid_phone_number('it', '0039 338 1234567'), t('Test invalid - 0039 338 1234567')); - $this->assertFalse(valid_phone_number('it', '(338)1234567'), t('Test invalid - (338)1234567')); + $this->assertFalse(valid_phone_number('it', '(338)1234567'), t('Test invalid - (338)1234567')); } public function testPhoneITFormatting() { - //$this->assertEqual(format_phone_number('it', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('it', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } } - diff --git a/tests/phone.jo.test b/tests/phone.jo.test index aeeb14e..ca0d7e9 100644 --- a/tests/phone.jo.test +++ b/tests/phone.jo.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('jo', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('jo', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.nl.test b/tests/phone.nl.test index 6886399..23d86b1 100644 --- a/tests/phone.nl.test +++ b/tests/phone.nl.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('nl', '021 3012 3456'), t('Test invalid ')); + //$this->assertFalse(valid_phone_number('nl', '021 3012 3456'), t('Test invalid')); } public function testPhoneNLFormatting() { - //$this->assertEqual(format_phone_number('nl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('nl', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.nz.test b/tests/phone.nz.test index 57b7d1b..1983b79 100644 --- a/tests/phone.nz.test +++ b/tests/phone.nz.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('nz', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); - $this->assertEqual(format_phone_number('nz', '021123456', null), '(021) 123 456', t('Check 6-digit domestic mobile format')); - $this->assertEqual(format_phone_number('nz', '0211234567', null), '(021) 123 4567', t('Check 7-digit domestic mobile format')); - $this->assertEqual(format_phone_number('nz', '+64211234567', null), '+64 21 123 4567', t('Check 7-digit international mobile format')); - $this->assertEqual(format_phone_number('nz', '02101234567', null), '(021) 0123 4567', t('Check 8-digit domestic mobile format')); - $this->assertEqual(format_phone_number('nz', '+642101234567', null), '+64 21 0123 4567', t('Check 8-digit international mobile format')); - $this->assertEqual(format_phone_number('nz', '041234567', null), '(04) 123 4567', t('Check regional number format (domestic)')); - $this->assertEqual(format_phone_number('nz', '+6441234567', null), '+64 4 123 4567', t('Check regional number format (international)')); - $this->assertEqual(format_phone_number('nz', '041234567x1234', null), '(04) 123 4567 x1234', t('Check regional number format with extension (domestic)')); - $this->assertEqual(format_phone_number('nz', '+6441234567x1234', null), '+64 4 123 4567 x1234', t('Check regional number format with extension (international)')); - $this->assertEqual(format_phone_number('nz', '0800 83 83 83', null), '0800 838383', t('Check 0800 number formatting (6 digit)')); - $this->assertEqual(format_phone_number('nz', '0800 123 4567', null), '0800 123 4567', t('Check 0800 number formatting (7 digit)')); - $this->assertEqual(format_phone_number('nz', '0800 12345', null), '0800 12345', t('Check 0800 number formatting (5 digit)')); + $this->assertEqual(format_phone_number('nz', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); + $this->assertEqual(format_phone_number('nz', '021123456', NULL), '(021) 123 456', t('Check 6-digit domestic mobile format')); + $this->assertEqual(format_phone_number('nz', '0211234567', NULL), '(021) 123 4567', t('Check 7-digit domestic mobile format')); + $this->assertEqual(format_phone_number('nz', '+64211234567', NULL), '+64 21 123 4567', t('Check 7-digit international mobile format')); + $this->assertEqual(format_phone_number('nz', '02101234567', NULL), '(021) 0123 4567', t('Check 8-digit domestic mobile format')); + $this->assertEqual(format_phone_number('nz', '+642101234567', NULL), '+64 21 0123 4567', t('Check 8-digit international mobile format')); + $this->assertEqual(format_phone_number('nz', '041234567', NULL), '(04) 123 4567', t('Check regional number format (domestic)')); + $this->assertEqual(format_phone_number('nz', '+6441234567', NULL), '+64 4 123 4567', t('Check regional number format (international)')); + $this->assertEqual(format_phone_number('nz', '041234567x1234', NULL), '(04) 123 4567 x1234', t('Check regional number format with extension (domestic)')); + $this->assertEqual(format_phone_number('nz', '+6441234567x1234', NULL), '+64 4 123 4567 x1234', t('Check regional number format with extension (international)')); + $this->assertEqual(format_phone_number('nz', '0800 83 83 83', NULL), '0800 838383', t('Check 0800 number formatting (6 digit)')); + $this->assertEqual(format_phone_number('nz', '0800 123 4567', NULL), '0800 123 4567', t('Check 0800 number formatting (7 digit)')); + $this->assertEqual(format_phone_number('nz', '0800 12345', NULL), '0800 12345', t('Check 0800 number formatting (5 digit)')); } -} \ No newline at end of file +} diff --git a/tests/phone.pa.test b/tests/phone.pa.test index 88ecb29..e26a149 100644 --- a/tests/phone.pa.test +++ b/tests/phone.pa.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('pa', '64644334'), '6464-4334', '6464-4334 format'); $this->assertEqual(format_phone_number('pa', '6464 4334', array('phone_country_code' => 1)), '+507 6464-4334', 'add +507 to 6464 4334 format'); } -} \ No newline at end of file +} diff --git a/tests/phone.ph.test b/tests/phone.ph.test index c2e8929..cf85064 100644 --- a/tests/phone.ph.test +++ b/tests/phone.ph.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('ph', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('ph', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.pk.test b/tests/phone.pk.test index b2fafc5..f7cc68b 100644 --- a/tests/phone.pk.test +++ b/tests/phone.pk.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('pk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('pk', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.pl.test b/tests/phone.pl.test index 0996f46..ad39ad4 100644 --- a/tests/phone.pl.test +++ b/tests/phone.pl.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('pl', '+47 100-100-100'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('pl', '1000-100-100'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('pl', '1000000000'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('pl', '+47 100-100-100'), t('Test invalid')); + $this->assertFalse(valid_phone_number('pl', '1000-100-100'), t('Test invalid')); + $this->assertFalse(valid_phone_number('pl', '1000000000'), t('Test invalid')); } public function testPhonePLFormatting() { - //$this->assertEqual(format_phone_number('pl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('pl', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.ru.test b/tests/phone.ru.test index ea4109a..ccb90e0 100644 --- a/tests/phone.ru.test +++ b/tests/phone.ru.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('ru', '8(913)448-51-90'), t('Test valid')); $this->assertTrue(valid_phone_number('ru', '903-345-34-34'), t('Test valid')); $this->assertTrue(valid_phone_number('ru', '903-34-334-34'), t('Test valid')); - $this->assertTrue(valid_phone_number('ru', '903-34-33434'), t('Test valid ')); + $this->assertTrue(valid_phone_number('ru', '903-34-33434'), t('Test valid')); } public function testPhoneRUInvalid() { - $this->assertFalse(valid_phone_number('ru', '+33903-34-33434'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('ru', '+33903-34-33434'), t('Test invalid')); } public function testPhoneRUFormatting() { - //$this->assertEqual(format_phone_number('ru', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('ru', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.se.test b/tests/phone.se.test index 2c5fde4..76432d1 100644 --- a/tests/phone.se.test +++ b/tests/phone.se.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('se', '46 08-123 456 78'), t('Test invalid')); - $this->assertFalse(valid_phone_number('se', '08 123 456 78'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('se', '0123 456 78'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('se', '08 123 456 78'), t('Test invalid')); + $this->assertFalse(valid_phone_number('se', '0123 456 78'), t('Test invalid')); $this->assertFalse(valid_phone_number('se', '34348abc'), t('Test invalid')); - $this->assertFalse(valid_phone_number('se', '452643242343432432435643623432'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('se', '532'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('se', '21003612-9999'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('se', '18790505-45458'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('se', '19740641-5559'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('se', '452643242343432432435643623432'), t('Test invalid')); + $this->assertFalse(valid_phone_number('se', '532'), t('Test invalid')); + $this->assertFalse(valid_phone_number('se', '21003612-9999'), t('Test invalid')); + $this->assertFalse(valid_phone_number('se', '18790505-45458'), t('Test invalid')); + $this->assertFalse(valid_phone_number('se', '19740641-5559'), t('Test invalid')); } public function testPhoneSEFormatting() { - //$this->assertEqual(format_phone_number('se', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('se', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.sg.test b/tests/phone.sg.test index 2ad8b88..32ef9d8 100644 --- a/tests/phone.sg.test +++ b/tests/phone.sg.test @@ -1,5 +1,10 @@ assertFalse(valid_phone_number('sg', '6123-4567'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('sg', '6-CALL-CPY'), t('Test invalid ')); - $this->assertFalse(valid_phone_number('sg', '6123abcd'), t('Test invalid ')); + $this->assertFalse(valid_phone_number('sg', '6123-4567'), t('Test invalid')); + $this->assertFalse(valid_phone_number('sg', '6-CALL-CPY'), t('Test invalid')); + $this->assertFalse(valid_phone_number('sg', '6123abcd'), t('Test invalid')); } public function testPhoneSGFormatting() { - //$this->assertEqual(format_phone_number('sg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('sg', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.ua.test b/tests/phone.ua.test index d1096cb..b493e99 100644 --- a/tests/phone.ua.test +++ b/tests/phone.ua.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('ua', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('ua', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } -} \ No newline at end of file +} diff --git a/tests/phone.uk.test b/tests/phone.uk.test index 2470a39..33dc061 100644 --- a/tests/phone.uk.test +++ b/tests/phone.uk.test @@ -1,5 +1,10 @@ assertTrue(valid_phone_number('uk', '+44(0)1970123456'), t('Test valid - +44(0)1970123456')); $this->assertTrue(valid_phone_number('uk', '+44 1970 123 4562'), t('Test valid - +44 1970 123 456')); $this->assertTrue(valid_phone_number('uk', '+44 (0)1970 123 456'), t('Test valid - +44 (0)1970 123 456')); - $this->assertTrue(valid_phone_number('uk', '(01970) 123456 #0001'), t('Test valid - (01970) 123456 #0001')); + $this->assertTrue(valid_phone_number('uk', '(01970) 123456 #0001'), t('Test valid - (01970) 123456 #0001')); } public function testPhoneUKInvalid() { @@ -32,10 +37,10 @@ class UKPhoneNumberTestCase extends DrupalWebTestCase { $this->assertFalse(valid_phone_number('uk', '(+441970)123456'), t('Test invalid - (+441970)123456')); $this->assertFalse(valid_phone_number('uk', '+44(1970)123456'), t('Test invalid - +44(1970)123456')); $this->assertFalse(valid_phone_number('uk', '+44 01970 123 456'), t('Test invalid - +44 01970 123 456')); - $this->assertFalse(valid_phone_number('uk', '(0197) 0123456 #01'), t('Test invalid - (0197) 0123456 #01')); + $this->assertFalse(valid_phone_number('uk', '(0197) 0123456 #01'), t('Test invalid - (0197) 0123456 #01')); } public function testPhoneUKFormatting() { - //$this->assertEqual(format_phone_number('uk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format')); + //$this->assertEqual(format_phone_number('uk', '+6421123456', NULL), '+64 21 123 456', t('Check international mobile format')); } } diff --git a/tests/phone.za.test b/tests/phone.za.test index 535148e..9b7f992 100644 --- a/tests/phone.za.test +++ b/tests/phone.za.test @@ -1,5 +1,10 @@ assertEqual(format_phone_number('za', '082 123 1234', null), '082 123 1234', 'Formatting OK "082 123 1234" --> "082 123 1234"'); + $this->assertEqual(format_phone_number('za', '082 123 1234', NULL), '082 123 1234', 'Formatting OK "082 123 1234" --> "082 123 1234"'); } -} \ No newline at end of file +}