@param string $data

@return int

@throws \Icicle\File\Exception\FileException
483487
public function write(string $data): int
    {
        $length = strlen($data);

        if (0 === $length) {
            return 0;
        }

        $written = @fwrite($this->handle, $data, $length);

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

        return $written;
    }
613781
public function write($handle, string $data, $length = null) : int
    {
        $bytesWritten = is_int($length) ? fwrite($handle, $data, $length) : fwrite($handle, $data);

        if (false === $bytesWritten) {
            throw new FileException('Cannot write to a file.');
        }

        return $bytesWritten;
    }
466281
public function setContents($data)
	{
		$level = error_reporting(0);
		$result = file_put_contents($this->getPathname(), $data);
		error_reporting($level);

		if (false === $result)
		{
			$error = error_get_last();
			throw new RuntimeException($error['message']);
		}

		return $result;
	}
591465
public static function count($data = false) {

        if ($data && Validate::isArray($data)) {

            return count($data);
        } else if ($data && Validate::isObject($data)) {

            return count(get_object_vars($data));
        }

        return 0;
    }
1341657
public function insert($data)
    {
        if(empty($data))
            throw new Exception("Can't insert an empty row");

        return $this->_connection->execute(sprintf(
            'INSERT INTO %s SET %s',
            $this->_name->quoted(),
            $this->_buildSet($data)
            ), array_values($data)
        );
    }
276606
private static function extractNumber($data)
    {
        $rknumhigh = self::getInt4d($data, 4);
        $rknumlow = self::getInt4d($data, 0);
        $sign = ($rknumhigh & 0x80000000) >> 31;
        $exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
        $mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
        $mantissalow1 = ($rknumlow & 0x80000000) >> 31;
        $mantissalow2 = ($rknumlow & 0x7fffffff);
        $value = $mantissa / pow(2, (20 - $exp));

        if ($mantissalow1 != 0) {
            $value += 1 / pow(2, (21 - $exp));
        }

        $value += $mantissalow2 / pow(2, (52 - $exp));
        if ($sign) {
            $value *= -1;
        }

        return $value;
    }
291154
public function tell(): int
    {
        $position = ftell($this->handle);

        if (false === $position) {
            $message = 'Could not get file pointer position.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return $position;
    }
1369318
public function writeBytes($data)
    {
        if ($this->isClosed) {
            // TODO: Should this be an error condition? e.g. BadMethodCallException
            return;
        }

        $bytesRead = 0;

        while ($bytesRead != strlen($data)) {
            $initialBufferLength = strlen($this->buffer);
            $this->buffer .= substr($data, $bytesRead, $this->chunkSize - $initialBufferLength);
            $bytesRead += strlen($this->buffer) - $initialBufferLength;

            if (strlen($this->buffer) == $this->chunkSize) {
                $this->insertChunkFromBuffer();
            }
        }

        return $bytesRead;
    }
232491
public function write($string) : int
	{
		if (! \is_resource($this->resource))
		{
			throw new Exception\UnwritableStreamException('Stream is not resourceable');
		}

		if (! $this->isWritable())
		{
			throw new Exception\UnwritableStreamException('Stream is not writable');
		}

		$result = \fwrite($this->resource, $string);

		if (false === $result)
		{
			throw new Exception\UnwritableStreamException('Unable to write to the stream');
		}

		return $result;
	}
542547
private static function _extractNumber($data)
	{
		$rknumhigh = self::_GetInt4d($data, 4);
		$rknumlow = self::_GetInt4d($data, 0);
		$sign = ($rknumhigh & 0x80000000) >> 31;
		$exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
		$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
		$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
		$mantissalow2 = ($rknumlow & 0x7fffffff);
		$value = $mantissa / pow( 2 , (20 - $exp));

		if ($mantissalow1 != 0) {
			$value += 1 / pow (2 , (21 - $exp));
		}

		$value += $mantissalow2 / pow (2 , (52 - $exp));
		if ($sign) {
			$value *= -1;
		}

		return $value;
	}
1345765
public function set($data) {
// 		debug('FSCache set', $data);
// 		debug('FSCache path '.$this->path, $this->editTime.static::$delim.serialize($data));
		try {
			return file_put_contents($this->path, $this->editTime.static::$delim.serialize($data));
		} catch( Exception $e ) {
			throw new CacheException($e->getMessage(), $e->getCode(), $e);
		}
	}
61301
public function decode($data)
    {
        $int = (int) ($decoded = parent::decode($data));

        return (string) $int === $decoded ? $int : 0;
    }
274841
public function stream_write(string $data): int
    {
        if (self::READONLY === $this->mode) {
            return 0;
        }

        if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            return 0;
        }

        if (self::$quota->isLimited()) {
            $data = substr($data, 0, self::$quota->spaceLeft(self::$root->sizeSummarized()));
        }

        return $this->content->write($data);
    }
1342303
public function stream_write($data)
    {
        if ($this->getOnWriteDataMode()) {

            $length = strlen($data);
            $this->appendDataBuffer($data);
            $this->appendPosition($length);
            return $length;
        } else {
            throw new \Exception('dirty mode.');
        }
    }
267675
protected function sendHeadRequest() : int
    {
        $response   = $this->getClient()->head($this->getUrl());
        $statusCode = $response->getStatusCode();

        if (HttpResponse::HTTP_OK !== $statusCode) {
            throw new FileException('File not found.');
        }

        return (int) current($response->getHeader('upload-offset'));
    }
1192805
public function parseContentLength($data)
    {
        $this->request->onData($data);
        $this->buffer.= $data;

        if (strlen($this->buffer) >= $this->contentLength) {
            $this->buffer = "";
            $this->notifyCompleted();
        }
    }
208324
public function fill($data)
    {
        if ($this->data) {
            throw new Exception('Trying to feel not empty context');
        }
        
        $this->data = $data;
        $this->version++;
    }