diff --git a/composer.json b/composer.json index 674def1..18976cd 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" }, "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); + } + } +}