public static function substring($str, $start, $end = null)
    {
        if ((0 > $start) && (0 < $end)) {
            $start = 0;
        }

        if (null === $end) {
            $end = self::length($str);
        }

        return \substr($str, $start, $end - $start);
    }