コード例 #1
0
 public function storageProvider()
 {
     $length = 200;
     $data = $this->generateString($length);
     $expectedChunk = new Chunk();
     $expectedChunk->setData($data);
     $expectedChunk->setHash($this->getFactory()->createHash($data));
     $expectedChunk->setLength($length);
     $expectedChunk->setPolicyCollection(new PolicyCollection());
     $this->getDatabase()->deleteAll();
     return array(array($expectedChunk));
 }
コード例 #2
0
 /**
  * @param $data
  *
  * @return ChunkInterface
  */
 public function upload($data)
 {
     $chunk = new Chunk();
     $chunk->setData($data);
     $chunk->setLength(strlen($data));
     $chunk->setPolicyCollection(new PolicyCollection());
     $chunk->setHash($this->factory->createHash($data));
     if ($this->database->contains($chunk->getHash(), Chunk::class)) {
         return $chunk;
     }
     return $this->database->store($chunk, array(ReplicatorInterface::OPTION_NAME => ReplicatorInterface::TYPE_FULL));
 }