This is a good idea, but it needs work.
- If I use
555-555-1234
and add a link to a phone number, it makes the linktel:+555-555-1234
. Phone numbers without a country code should not have a+
in front. - If I enter
tel:555-555-1234
, it still matches, but clicking the Phone match will make the linktel:+tel:555-555-1234
, which is definitely broken. This can be fixed with:
// Strip the tel: prefix to match only the phone part of the string. $string = str_replace('tel:', '', $string);
- If I use
- Using
filter_var($string, FILTER_SANITIZE_NUMBER_INT)
is a bad idea, and it's not used anywhere in Drupal code. - The code doesn't conform to Drupal coding standards.
- Telephone links aren't only for mobile phones. A computer can define an action for the tel: prefix, such as calling from your computer with Skype or Signal. Maybe say
Opens configured phone app to call @phone
. - The matcher needs tests. Look at EmailMatcherTest.php for an example.