Esempio n. 1
0
 /**
  * @param \Riak\Client\ProtoBuf\MapEntry[] $entry
  *
  * @return mixed
  */
 public function convertMapEntry(ProtoBuf\MapEntry $entry)
 {
     $field = $entry->getField();
     $type = $field->getType();
     if ($type === MapFieldType::MAP) {
         return $this->fromProtoBuf($entry->map_value);
     }
     if ($type === MapFieldType::SET) {
         return $entry->set_value;
     }
     if ($type === MapFieldType::FLAG) {
         return $entry->flag_value == ProtoBuf\MapUpdate\FlagOp::ENABLE;
     }
     if ($type === MapFieldType::COUNTER) {
         return $entry->counter_value;
     }
     if ($type === MapFieldType::REGISTER) {
         return $entry->register_value;
     }
     throw new InvalidArgumentException(sprintf('Unknown crdt field type : %s', $type));
 }
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Unknown crdt field type : UNKNOWN
  */
 public function testConvertUnknownMapEntryException()
 {
     $entry = new ProtoBuf\MapEntry();
     $field = new ProtoBuf\MapField();
     $entry->setField($field);
     $field->setType('UNKNOWN');
     $this->instance->convertMapEntry($entry);
 }