Esempio n. 1
0
 public static function buildFromJSON($json)
 {
     // TODO parse and verify json
     $json = json_decode($json);
     $signature = SignatureObject::createFromJSON(json_encode($json->signature));
     $builder = new CommentObjectBuilder();
     $builder->objectID($json->objectID)->targetID($json->targetID)->author($json->author)->comment($json->comment)->datePublished($json->datePublished)->signature($signature);
     if (property_exists($json, 'dateUpdated')) {
         $builder->dateUpdated($json->dateUpdated);
     }
     return $builder->build();
 }
Esempio n. 2
0
 public function __construct(CommentObjectBuilder $builder)
 {
     parent::__construct($builder->getObjectID(), $builder->getTargetID());
     $this->author = $builder->getAuthor();
     $this->comment = $builder->getComment();
     $this->datePublished = $builder->getDatePublished();
     $this->dateUpdated = $builder->getDateUpdated();
     $this->signature = $builder->getSignature();
 }
Esempio n. 3
0
 public function testComment()
 {
     $comment = (new CommentObjectBuilder())->objectID(UOID::createUOID())->targetID(UOID::createUOID())->author(Sonic::getContextGlobalID())->comment('test comment')->build();
     $this->assertTrue($comment->validate());
     $this->assertEquals($comment, CommentObjectBuilder::buildFromJSON($comment->getJSONString()));
 }