Ejemplo n.º 1
0
 private function getSerialized(Snak $snak)
 {
     $serialization = array('snaktype' => $snak->getType(), 'property' => $snak->getPropertyId()->getSerialization());
     if ($this->serializeWithHash) {
         $serialization['hash'] = $snak->getHash();
     }
     if ($snak instanceof PropertyValueSnak) {
         $serialization['datavalue'] = $this->dataValueSerializer->serialize($snak->getDataValue());
     }
     return $serialization;
 }
Ejemplo n.º 2
0
 /**
  * @since 0.4
  *
  * @param SnakList $qualifiers
  * @param Summary $summary
  *
  * @throws ChangeOpException
  */
 protected function setQualifier(SnakList $qualifiers, Summary $summary = null)
 {
     if (!$qualifiers->hasSnakHash($this->snakHash)) {
         throw new ChangeOpException("Qualifier with hash {$this->snakHash} does not exist");
     }
     if ($qualifiers->hasSnak($this->snak)) {
         throw new ChangeOpException('The statement has already a qualifier with hash ' . $this->snak->getHash());
     }
     $qualifiers->removeSnakHash($this->snakHash);
     $qualifiers->addSnak($this->snak);
     $this->updateSummary($summary, 'update', '', $this->getSnakSummaryArgs($this->snak));
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider snakProvider
  * @param Snak $snak
  */
 public function testGetHash(Snak $snak)
 {
     $hash = $snak->getHash();
     $this->assertInternalType('string', $hash);
     $this->assertEquals($hash, $snak->getHash());
 }
Ejemplo n.º 4
0
 /**
  * @see Hashable::getHash
  *
  * @since 0.1
  *
  * @return string
  */
 public function getHash()
 {
     return sha1(implode('|', array(sha1($this->mainSnak->getHash() . $this->qualifiers->getHash()), $this->rank, $this->references->getValueHash())));
 }
Ejemplo n.º 5
0
 /**
  * @see Snaks::removeSnak
  *
  * @since 0.1
  *
  * @param Snak $snak
  */
 public function removeSnak(Snak $snak)
 {
     $this->removeByElementHash($snak->getHash());
 }