code: public function write($path, $contents, $blocking = false)
  	{
  		$flockFlags = $blocking ? LOCK_EX : LOCK_EX | LOCK_NB;
  
  		$file = fopen($path, 'c');
  
  		if (!flock($file, $flockFlags)) {
  			fclose($file);
  			throw new IOException("Could not aquire file lock for file: $path");
  		}
  
  		ftruncate($file, 0);
  		fwrite($file, $contents);
  		fflush($file);
  		flock($file, LOCK_UN | LOCK_NB);
  		fclose($file);
  	}
docs: Write to the file.
  
  @param  string $path Path to the file.
  @param  string $contents Contents to write to the file.
  @param  bool   $blocking Wait for other locks to expire rather than
  throwing an error when a lock cannot be aquired.
  
  @return void
  
  @throws IOException