Ejemplo n.º 1
0
 /**
  * Creates a new JSON based file store.
  *
  * @param string $cassettePath Path to the cassette directory.
  * @param string $cassetteName Path to a file, will be created if not existing.
  */
 public function __construct($cassettePath, $cassetteName)
 {
     $file = $cassettePath . DIRECTORY_SEPARATOR . $cassetteName;
     if (!file_exists($file)) {
         file_put_contents($file, '[]');
     }
     Assertion::file($file, "Specified path '{$file}' is not a file.");
     Assertion::readable($file, "Specified file '{$file}' must be readable.");
     Assertion::writeable($file, "Specified path '{$file}' must be writeable.");
     $this->handle = fopen($file, 'r+');
     $this->filePath = $file;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new YAML based file store.
  *
  * @param string $cassettePath Path to the cassette directory.
  * @param string $cassetteName Path to a file, will be created if not existing.
  * @param Parser $parser Parser used to decode yaml.
  * @param Dumper $dumper Dumper used to encode yaml.
  */
 public function __construct($cassettePath, $cassetteName, Parser $parser = null, Dumper $dumper = null)
 {
     $file = $cassettePath . DIRECTORY_SEPARATOR . $cassetteName;
     if (!file_exists($file)) {
         file_put_contents($file, '');
     }
     Assertion::file($file, "Specified path '{$file}' is not a file.");
     Assertion::readable($file, "Specified file '{$file}' must be readable.");
     Assertion::writeable($file, "Specified path '{$file}' must be writable.");
     $this->handle = fopen($file, 'r+');
     $this->yamlParser = $parser ?: new Parser();
     $this->yamlDumper = $dumper ?: new Dumper();
 }