3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Refinery29\Core; final class Util { const R29STATIC_DOMAIN = 's%d.r29static.com'; /** * @param string $text * @param string $spacer * * @return array|mixed|string */ public static function tagify($text, $spacer = '-') { //Handle if array if (is_array($text)) { return array_map("self::tagify", $text); } $text = self::decodeHtml($text); $text = self::normalizeStr($text); $text = str_replace('&', 'and', $text); return str_replace(' ', $spacer, trim(preg_replace('#([^a-z0-9/]+)#', ' ', strtolower($text)))); } /** * @param string $text * * @return string */ public static function decodeHtml($text) { return html_entity_decode($text, ENT_QUOTES, 'UTF-8'); } /** * @param string $text * * @return string */ public static function normalizeStr($text) { $map = [ 'Š' => 'S', 'š' => 's', 'Ð' => 'Dj','Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'ƒ' => 'f', ]; return strtr($text, $map); } /** * @param $path * @param mixed|string $app * @param string $scheme * * @return string */ public static function r29StaticAlias($path, $app = APP_NAME, $scheme = null) { // there is no bin app, bin is passed for images served by the cms if ($app === 'bin') { $path = preg_replace('#^/static/#', '/', $path); } else { $path = sprintf('%s/%s/%s', $app, rev(), $path); } $domain = sprintf(Util::R29STATIC_DOMAIN, Util::hashmod($path, 3) + 1); $url = sprintf('//%s/%s', $domain, $path); if (! empty($scheme) && strpos($url, 'http') !== 0) { $url = sprintf('%s:%s', $scheme, $url); } return $url; } /** * @param $str * @param $max * * @return int */ public static function hashmod($str, $max) { return crc32($str) % $max; } } var_dump(Refinery29\Core\Util::tagify(['sethomg john', 'yolo oko']));
based on os8np
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'Refinery29\Core\Refinery29\Core\Util' not found in /in/TXjYB:100 Stack trace: #0 {main} thrown in /in/TXjYB on line 100
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Fatal error: Class 'Refinery29\Core\Refinery29\Core\Util' not found in /in/TXjYB on line 100
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/TXjYB on line 48
Process exited with code 255.