public function getSize()
    {
        // If the stream is a file based stream and local, then use fstat
        clearstatcache(true, $this->getPath());

        $info = $this->getInfo();

        if (isset($info['size'])) {
            $size = $info['size'];
        } else {
            $size = strlen((string) $this->toString());
        }

        return $size;
    }