From 147d622c325a356d74bf128afbfde19e3202f6ea Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 16 Nov 2016 13:51:49 +0100 Subject: [PATCH] add polyfill to for the idn calls --- composer.json | 7 ++++--- src/polyfill.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/polyfill.php diff --git a/composer.json b/composer.json index 674def1..5e8209d 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,9 @@ ], "require": { "php": ">=5.5", - "symfony/polyfill-intl-icu": "^1.0", "layershifter/tld-database": "^1.0", - "layershifter/tld-support": "^1.1" + "layershifter/tld-support": "^1.1", + "true/punycode": "^2.1.1" }, "require-dev": { "codeclimate/php-test-reporter": "dev-master", @@ -29,7 +29,8 @@ }, "autoload": { "files": [ - "src/static.php" + "src/static.php", + "src/polyfill.php" ], "psr-4": { "LayerShifter\\TLDExtract\\": "src/" diff --git a/src/polyfill.php b/src/polyfill.php new file mode 100644 index 0000000..e13d3e6 --- /dev/null +++ b/src/polyfill.php @@ -0,0 +1,52 @@ +encode($domain); + } + } + + if (!function_exists('idn_to_ascii')) { + + /** + * Polyfill for idn_to_ascii. + * + * @link http://php.net/manual/de/function.idn-to-ascii.php + * + * @param string $domain + * + * @return string + */ + function idn_to_ascii($domain) + { + $punyCode = new Punycode(); + + return $punyCode->decode($domain); + } + } +}