public static function replace($text, $search, $replace, $max = -1)
    {
        if ((true === self::isEmpty($text))
            || (true === self::isEmpty($search))
            || (null === $replace)
            || (0 === $max)
        ) {
            return $text;
        }

        return \preg_replace(
            '/' . \preg_quote($search) . '/',
            $replace,
            $text,
            $max
        );
    }