Ikwattro\GuzzleStereo\Store\Writer::write PHP Method

write() public method

public write ( string $file, mixed $content )
$file string
$content mixed
    public function write($file, $content)
    {
        if (!$this->isStoreWritable()) {
            throw new RecorderException(sprintf('The directory "%s" is not writable', $this->storeLocation));
        }
        file_put_contents($this->storeLocation . DIRECTORY_SEPARATOR . $file, $content);
    }

Usage Example

Beispiel #1
0
 /**
  * Dumps the tapes on disk.
  */
 public function dump()
 {
     foreach ($this->tapes as $tape) {
         if ($tape->hasResponses()) {
             $fileName = 'record_' . $tape->getName() . '.json';
             $content = $this->formatter->encodeResponsesCollection($tape->getResponses());
             $this->writer->write($fileName, $content);
         }
     }
 }