/** * @dataProvider getInvalidMessageRefs * * @param string $string */ public function testInvalidMessageRefs($string) { try { $ref = MessageRef::fromString($string); } catch (\Exception $e) { $this->assertTrue(true, sprintf('MessageRef correctly failed on string [%s].', $string)); return; } $this->fail(sprintf('MessageRef accepted and invalid string [%s].', $string)); }
/** * @param MessageRef $other * @return bool */ public function equals(MessageRef $other) { return $this->toString() === $other->toString(); }
/** * @param mixed $value * @param Field $field * * @return MessageRef */ public function decodeMessageRef($value, Field $field) { return MessageRef::fromArray($value); }
/** * @param MessageRef $messageRef * @param Field $field * * @return mixed */ public function encodeMessageRef(MessageRef $messageRef, Field $field) { return ['M' => ['curie' => [self::TYPE_STRING => $messageRef->getCurie()->toString()], 'id' => [self::TYPE_STRING => $messageRef->getId()], 'tag' => $messageRef->hasTag() ? [self::TYPE_STRING => $messageRef->getTag()] : ['NULL' => true]]]; }