src/JmesPath/Utils.php
public static function slice($value, $start = null, $stop = null, $step = 1)
    {
        if (!Utils::isArray($value) && !is_string($value)) {
            throw new \InvalidArgumentException('Expects string or array');
        }

        return self::sliceIndices($value, $start, $stop, $step);
    }
public static function slice($value, $start = null, $stop = null, $step = 1)
    {
        if (!Utils::isArray($value) && !is_string($value)) {
            throw new \InvalidArgumentException('Expects string or array');
        }

        return self::sliceIndices($value, $start, $stop, $step);
    }
Creates a Python-style slice of a string or array.

@param array|string $value Value to slice
@param int|null     $start Starting position
@param int|null     $stop  Stop position
@param int          $step  Step (1, 2, -1, -2, etc.)

@return array|string
@throws \InvalidArgumentException