Take first x fields
@param int $length
@return \PerrysLambda\ArrayList
343121
public function take($length)
    {
        if(!is_int($length))
        {
            throw new \InvalidArgumentException();
        }

        if($length>=0 && $length>$this->length())
        {
            $length = $this->length();
        }
        elseif($length<0 && $length<(0-$this->length()))
        {
            $length = 0-$this->length();
        }

        $temp = $this->newInstance();

        if($length>=0)
        {
            $temp->setData(array_slice($this->getData(), 0, $length));
        }
        else
        {
            $temp->setData(array_slice($this->getData(), $length));
        }

        return $temp;
    }
442941
public function substring($start, $length = NULL) {
        //TODO: Fix to PHP #42101
        if($length === NULL) {
            $newValue = mb_substr($this->string, $start);
        } else {
            $newValue = mb_substr($this->string, $start, $length);
        }

        return $this->createClone($newValue);
    }
679625
protected function _bufferSize($length)
    {
        if ($this->_limit !== null) {
            $position = $this->tell();
            $max = $this->_start + $this->_limit;
            $length = $max - $position;
        }
        if ($length === null) {
            $length = $this->_bufferSize;
        }
        return $length;
    }
659547
public function generate($length)
    {
        $realPool = $this->mergePools($this->characterPools);
        $max = (count($realPool) - 1);
        mt_srand();

        $randomString = '';

        for ($i = 0; $i < $length; $i++) {
            $randomString .= $realPool[mt_rand(0, $max)];
        }

        return $randomString;
    }
590498
public function substring($start, $length = null){
		
		if(!$this->offsetExists($start)){
			throw new \OutOfRangeException('$start is an invalid index');
		}
		
		if($length !== null && !\is_numeric($length) || $length < 0){
			throw new \InvalidArgumentException('$length is invalid');
		}
		
		return new static(\mb_substr($this->_Value, $start, $length, $this->_Encoding),
				$this->_Encoding);
		
	}
1149344
public function asString(StringLength $length = null)
    {
        return $this->handleFilter(
                function() use($length)
                {
                    return filter\RangeFilter::wrap(
                            filter\StringFilter::instance(),
                            $length
                    );
                }
        );
    }
412474
public function getSlice($offset, $length)
    {
        $query = clone $this->query;
        $query->offset = $offset;
        $query->limit = $length;
        $query->performCount = false;

        $searchResult = $this->filterService->filterContent($query);

        // Set count for further use if returned by search engine despite !performCount (Solr, ES)
        if (null === $this->nbResults && null !== $searchResult->totalCount) {
            $this->nbResults = $searchResult->totalCount;
        }

        $list = [];
        foreach ($searchResult->searchHits as $hit) {
            $list[] = $hit->valueObject;
        }

        return $list;
    }
1168151
public function length($length = 2)
    {
        $this->length = (int) $length;
        $this->initials = $this->generateInitials();

        return $this;
    }
385654
public function cutStart($length) {
		$rawString = mb_substr($this->rawString, $length, null, $this->charset);

		return new static($rawString, $this->charset);
	}
357622
public function slice($offset, $length = null): CollectionInterface
    {
        if ($length < 0) {
            throw new InvalidArgumentException('Negative slice lengths are not supported');
        }

        $result = $this;
        if ($offset < 0) {
            $result = $this->take($offset);
        } elseif ($offset > 0) {
            $result = $this->offset($offset);
        }

        if ($length !== null) {
            $result = $result->take($length);
        }

        return $result;
    }
1202848
public function substr(int $start, int $length = null): self
    {
        if ($start < 0) {
            throw new InvalidArgumentException('Negative index is not allowed!');
        }

        return new static(mb_substr($this->data, $start, $length, $this->encoding), $this->encoding);
    }
941164
public function setLength($length)
    {
        if ($length !== null) {
            $this->_length = (int) $length;
        } else {
            $this->_length = null;
        }

        return $this;
    }
606860
public function slice(int $offset, ?int $length = null): ArrayCollection
    {
        return new static(array_slice($this->items, $offset, $length, true));
    }
794493
public function setLength($length = null)
    {
        $length = (null === $length) ? $this->datasetCount : $length;
        $this->length = (\abs($length) > $this->datasetCount) ? $this->datasetCount : $length;

        return $this;
    }
1192817
public function slice($offset, $length = null)
    {
        $this->tags = array_slice($this->tags, $offset, $length, true);

        return $this;
    }
965534
public function length($length = null)
    {
        if (!is_null($length)) {
            $this->length = (int) $length;
        }

        return $this->length;
    }
121630
public function generateText($length = 5) {
		
		if(false === ('-' . intval($length) == '-' . $length)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($length)), E_USER_ERROR);
		}

		$caseinsensitive = ['a', 'b', 'c', 'd', 'e', 'f', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'];
		$casesensitive 	 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
		$numbers_arr 	 = [3, 4, 5, 6, 7, 8, 9];
		$array 			 = array_merge(array_merge($caseinsensitive, $casesensitive), $numbers_arr);
		$str 			 = '';

		for($i = 0; $i < $length; $i++) {
			$str .= $array[array_rand($array, 1)];
		}

		return $str;
	}