コード例 #1
0
ファイル: Vcr.php プロジェクト: php-http/vcr-plugin
 /**
  * Inserts the given tape.
  *
  * If an actual tape is provided, it is inserted directly.
  * If the name of a tape is provided, it will be fetched from the shelf, or created with the given name.
  *
  * @param Tape|string $tape
  *
  * @throws InvalidState If the tape could not be inserted.
  */
 public function insert($tape)
 {
     if ($this->tape) {
         throw new InvalidState(sprintf('Please eject the tape "%s" first.', $this->tape->getName()));
     }
     if (!$tape instanceof Tape) {
         try {
             $tape = $this->storage->fetch($tape);
         } catch (NotFound $e) {
             $tape = new Tape($tape);
         }
     }
     $this->tape = $tape;
 }
コード例 #2
0
ファイル: FileStorage.php プロジェクト: php-http/vcr-plugin
 public function store(Tape $tape)
 {
     $filePath = $this->getFilePathForName($tape->getName());
     file_put_contents($filePath, serialize($tape));
 }
コード例 #3
0
 public function store(Tape $tape)
 {
     $key = $this->createKey($tape->getName());
     $this->tapes[$key] = $tape;
 }