src/Storage/File/FileWriter.php
public function write($data)
    {
        if (!is_string($data)) {
            throw new \InvalidArgumentException("The data is not a string.");
        }

        $this->open();

        if (!ftruncate($this->handle, 0)) {
            $this->writeErrors = true;
            throw new \RuntimeException("Could not truncate file " . $this->filePath);
        }
        
        fseek($this->handle, 0);
        
        $res = fwrite($this->handle, $data);
        if (strlen($data) !== $res) {
            $this->writeErrors = true;
            throw new \RuntimeException("Could not write to file " . $this->filePath);
        }
    }
public function write($data)
    {
        if (!is_string($data)) {
            throw new \InvalidArgumentException("The data is not a string.");
        }

        $this->open();

        if (!ftruncate($this->handle, 0)) {
            $this->writeErrors = true;
            throw new \RuntimeException("Could not truncate file " . $this->filePath);
        }
        
        fseek($this->handle, 0);
        
        $res = fwrite($this->handle, $data);
        if (strlen($data) !== $res) {
            $this->writeErrors = true;
            throw new \RuntimeException("Could not write to file " . $this->filePath);
        }
    }
public function write ( $ data ) { if ( ! is_string ( $ data ) ) { throw new \ InvalidArgumentException ( "The data is not a string." ) ; } $ this -> open ( ) ; if ( ! ftruncate ( $ this -> handle , 0 ) ) { $ this -> writeErrors = true ; throw new \ RuntimeException ( "Could not truncate file " . $ this -> filePath ) ; } fseek ( $ this -> handle , 0 ) ; $ res = fwrite ( $ this -> handle , $ data ) ; if ( strlen ( $ data ) !== $ res ) { $ this -> writeErrors = true ; throw new \ RuntimeException ( "Could not write to file " . $ this -> filePath ) ; } }
Writes contents of the file

@param string $data Data to write
@throws \InvalidArgumentException data not a string
@throws \RuntimeException Write error
Writes contents of the file