[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace Algo26\IdnaConvert; 4 5 use InvalidArgumentException; 6 7 abstract class AbstractIdnaConvert 8 { 9 abstract public function convert(string $host): string; 10 11 /** 12 * @param string $emailAddress 13 * 14 * @return string 15 */ 16 public function convertEmailAddress(string $emailAddress): string 17 { 18 if (strpos($emailAddress, '@') === false) { 19 throw new InvalidArgumentException('The given string does not look like an email address', 206); 20 } 21 22 $parts = explode('@', $emailAddress); 23 24 return sprintf( 25 '%s@%s', 26 $parts[0], 27 $this->convert($parts[1]) 28 ); 29 } 30 31 /** 32 * @param string $url 33 * 34 * @return string 35 */ 36 public function convertUrl(string $url): string 37 { 38 $parsed = parse_url($url); 39 if ($parsed === false) { 40 throw new InvalidArgumentException('The given string does not look like a URL', 206); 41 } 42 43 // Nothing to do 44 if (!isset($parsed['host']) || $parsed['host'] === null) { 45 return $url; 46 } 47 $parsed['host'] = $this->convert($parsed['host']); 48 49 return http_build_url($parsed); 50 } 51 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |