private function getCacheId(Description $description, QueryOptions $queryOptions = null, $entityType)
 {
     $key = self::CACHE_ID_PREFIX . WIKIBASE_DATAMODEL_VERSION . '-' . $entityType . '-' . $description->getHash();
     if ($queryOptions !== null) {
         $key .= '-' . $queryOptions->getOffset() . '-' . $queryOptions->getLimit();
     }
     return $key;
 }
Esempio n. 2
0
 /**
  * @see Hashable::getHash
  *
  * @since 1.0
  *
  * @return string
  */
 public function getHash()
 {
     if ($this->hash === null) {
         $this->hash = sha1($this->getType() . $this->propertyId->getHash() . $this->subDescription->getHash() . $this->isSubProperty);
     }
     return $this->hash;
 }
 protected function getDescriptionValueSerialization(Description $description)
 {
     if ($description instanceof AnyValue) {
         return array();
     }
     if ($description instanceof SomeProperty) {
         return array('property' => $description->getPropertyId()->toArray(), 'description' => $this->serialize($description->getSubDescription()), 'isSubProperty' => $description->isSubProperty());
     }
     if ($description instanceof ValueDescription) {
         return array('value' => $description->getValue()->toArray(), 'comparator' => $this->getStringForComparator($description->getComparator()));
     }
     if ($description instanceof DescriptionCollection) {
         $serializationMethod = array($this, 'serialize');
         return array('descriptions' => array_map(function (Description $description) use($serializationMethod) {
             return call_user_func($serializationMethod, $description);
         }, $description->getDescriptions()));
     }
     throw new UnsupportedObjectException($description);
 }
Esempio n. 4
0
 /**
  * @dataProvider instanceProvider
  *
  * @since 1.0
  *
  * @param Description $description
  */
 public function testGetHashStability(Description $description)
 {
     $this->assertEquals($description->getHash(), $description->getHash());
 }