public function __construct(ProfileObjectBuilder $builder) { parent::__construct($builder->getObjectID()); $this->setGlobalID($builder->getGlobalID()); $this->setDisplayName($builder->getDisplayName()); $this->setParamArray($builder->getParamArray()); }
public static function buildFromJSON($json) { // TODO parse and verify json $jsonObject = json_decode($json); $builder = new ProfileObjectBuilder(); $builder->objectID($jsonObject->objectID)->globalID($jsonObject->globalID)->displayName($jsonObject->displayName); foreach (json_decode($json, true) as $key => $value) { if ($key != 'objectID' && $key != 'globalID' && $key != 'displayName' && $key != '@context' && $key != '@type') { $builder->param($key, $value); } } return $builder->build(); }
public function testProfile() { $profile = (new ProfileObjectBuilder())->globalID(Sonic::getContextGlobalID())->displayName($this->aliceSocialRecord->getDisplayName())->param('x', 'y')->build(); $this->assertTrue($profile->validate()); $this->assertEquals($profile, ProfileObjectBuilder::buildFromJSON($profile->getJSONString())); }