@param int $length

@return string

@throws \Icicle\File\Exception\FileException
173550
public function read(int $length): string
    {
        $data = @fread($this->handle, $length);

        if (false === $data || '' === $data) {
            $message = 'Could not read from the file.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return $data;
    }
38153
protected function read($length) {
		if ($this->length < $length) {
			throw new \Exception('Reading while at end of stream');
		}
		$output = substr($this->data, 0, $length);
		$this->data = substr($this->data, $length);
		$this->length -= $length;
		return $output;
	}
816445
public function gets($length = 0)
	{
		if (!$this->fh)
		{
			throw new FilesystemException('File not open');
		}

		// Capture PHP errors
		$php_errormsg = 'Error Unknown';
		$trackErrors  = ini_get('track_errors');
		ini_set('track_errors', true);

		switch ($this->processingmethod)
		{
			case 'gz':
				$res = $length ? gzgets($this->fh, $length) : gzgets($this->fh);

				break;

			case 'bz':
			case 'f':
			default:
				$res = $length ? fgets($this->fh, $length) : fgets($this->fh);

				break;
		}

		// Restore error tracking to what it was before
		ini_set('track_errors', $trackErrors);

		if (!$res)
		{
			throw new FilesystemException($php_errormsg);
		}

		// Return the result
		return $res;
	}
1078518
static function getRandomString($length = 8)
    {

        $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

        $value = '';
        $charsLength = strlen($chars) - 1;

        for ($i = 1 ; $i <= $length; $i++) {
            $value .= $chars[rand(0, $charsLength)];
        }

        return $value;

    }
413414
protected function _fread($length=1)
    {
        if ($length == 0) {
            return '';
        }

        if ($length < 1024) {
            return fread($this->_fileHandle, $length);
        }

        $data = '';
        while ( $length > 0 && ($nextBlock = fread($this->_fileHandle, $length)) != false ) {
            $data .= $nextBlock;
            $length -= strlen($nextBlock);
        }
        return $data;
    }
895770
private function setLength($length)
    {
        try {
            $this->length = (float)$length;
            unset($length);
            return 0;
        } catch (\Exception $e) {
            throw $e;
        }
    }
862458
public function generateRandomString($length)
    {
        do {
            $bytes = base64_encode($this->random->nextBytes($length));
            $string = substr(strtr($bytes, array('+' => '', '/' => '', '=' => '')), 0, $length);
        } while (strlen($string) < $length);
        return $string;
    }
119774
public function read(int $length = 8192): string
    {
        $bytes           = substr($this->buffer, $this->position, $length);
        $this->position += strlen($bytes);
        return $bytes;
    }
873301
public function generateRandomKey(int $length = 32): string
    {
        if ($length < 1) {
            throw new \RuntimeException('First parameter ($length) must be greater than 0');
        }

        // always use random_bytes() if it is available
        if (\function_exists('random_bytes')) {
            return \random_bytes($length);
        }
        throw new \RuntimeException('Function random_bytes not found');
    }
1189491
final protected function fgets($length = null)
	{
		if (! is_int($length)) {
			$length = $this->fstat('size');
		}
		return fgets($this->fhandle, $length);
	}
818674
final protected function fread($length = null)
	{
		if (! is_int($length)) {
			$length = $this->fstat('size');
		}
		return fread($this->fhandle, $length);
	}
86951
public function readBytes($length)
    {
        if (($length + $this->_needle) > $this->_streamLength) {
            throw new Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
        }
        $bytes = $this->_mbStringFunctionsOverloaded ? mb_substr($this->_stream, $this->_needle, $length, '8bit') : substr($this->_stream, $this->_needle, $length);
        $this->_needle+= $length;
        return $bytes;
    }
608699
public static function generateUniqueRandomAlphaNumericString($length){
        if(!function_exists('openssl_random_pseudo_bytes'))
            throw new Exception("openssl_random_pseudo_bytes is not defined!");

        if($length % 2 == 0)
            return bin2hex(openssl_random_pseudo_bytes($length));

        return substr(bin2hex(openssl_random_pseudo_bytes($length + 1)), 0, -1);
    }
192900
public static function randomString(int $length): string
    {
        $random = '';
        $passes = 0;

        do {
            foreach (str_split(openssl_random_pseudo_bytes($length * 3)) as $c) {
                $ascii = ord($c);

                if ($ascii >= 48 && $ascii <= 57 || $ascii >= 65 && $ascii <= 90 || $ascii >= 97 && $ascii <= 122) {
                    $random .= chr($ascii);
                }
            }
        } while (strlen($random) < $length && $passes++ < 50);

        if ($passes == 50) {
            throw new Exception('Unable to generate random string even after a lot passes... something is really wrong!');
        }

        return substr($random, 0, $length);
    }
143195
public static function randomLatinNumeric(int $length): string
    {
        $ret = 97;
        $out = null;
        for ($i = 0; $i < $length; $i++) {
            $offset = mt_rand(0, 15);
            $char = chr($ret + $offset);
            $posibility = mt_rand(0, 2);
            if ($posibility == 0) {
                // 33% - add random numeric
                $out .= mt_rand(0, 9);
            } elseif ($posibility == 1) {
                // 33% - make upper offset+ret
                $out .= strtoupper($char);
            } else {
                $out .= $char;
            }
        }
        return $out;
    }
599538
private static function generateRandomString($length = 10)
    {
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $string = '';

        for ($i = 0; $i < $length; $i++) {
            $string .= $characters[rand(0, strlen($characters) - 1)];
        }

        return $string;
    }
474627
protected function read($length)
    {
        if (!is_int($length) || $length < 1) {
            throw new LogicException('Argument must be positive integer', self::E_PARAMETER);
        }

        if (!$data = @fread($this->fileHandle, $length)) {
            throw new RuntimeException('Cannot not read from filename', self::E_FILE_READ);
        }

        return $data;
    }