src/Primitive/Support/Traits/SliceableTrait.php
public function slice($args)
    {
        if ( ! is_string($args) || strpos($args, ':') === false)
        {
            throw new InvalidArgumentException('Arguments should be string and slice `:` operator should present');
        }

        $args = explode(':', $args);

        // Too many colons, invalid slice syntax
        if (count($args) > 3)
        {
            throw new InvalidArgumentException('Too many slice arguments');
        }

        // Get slice arguments
        for ($i = 0; $i < 3; $i++)
        {
            if (isset($args[$i]) && $args[$i] !== '')
            {
                $args[$i] = (int) $args[$i];
            }
            else
            {
                $args[$i] = null;
            }
        }

        return call_user_func_array([$this, 'getSlice'], $args);
    }
public function slice($args)
    {
        if ( ! is_string($args) || strpos($args, ':') === false)
        {
            throw new InvalidArgumentException('Arguments should be string and slice `:` operator should present');
        }

        $args = explode(':', $args);

        // Too many colons, invalid slice syntax
        if (count($args) > 3)
        {
            throw new InvalidArgumentException('Too many slice arguments');
        }

        // Get slice arguments
        for ($i = 0; $i < 3; $i++)
        {
            if (isset($args[$i]) && $args[$i] !== '')
            {
                $args[$i] = (int) $args[$i];
            }
            else
            {
                $args[$i] = null;
            }
        }

        return call_user_func_array([$this, 'getSlice'], $args);
    }
Implements python-like string slices. Slices the string if the offset
contains at least a single colon. Slice notation follow the format
"start:stop:step". If no colon is present, returns the character at the
given index. Offsets may be negative to count from the last character in
the string. Throws an exception if the index does not exist, more than 3
slice args are given, or the step is 0.

@param mixed $args The index from which to retrieve the char, or a
string with colons to return a slice

@return static                    The string corresponding to the index
or slice
@throws \OutOfBoundsException     If a positive or negative offset does
not exist
@throws InvalidArgumentException If more than 3 slice arguments are
given, or step is 0