コード例 #1
0
 public static function fromModel(ActorModel $model)
 {
     $inverseFunctionalIdentifier = $model->getInverseFunctionalIdentifier();
     $actor = new self();
     $actor->mboxSha1Sum = $inverseFunctionalIdentifier->getMboxSha1Sum();
     $actor->openId = $inverseFunctionalIdentifier->getOpenId();
     if (null !== ($mbox = $inverseFunctionalIdentifier->getMbox())) {
         $actor->mbox = $mbox->getValue();
     }
     if (null !== ($account = $inverseFunctionalIdentifier->getAccount())) {
         $actor->accountName = $account->getName();
         $actor->accountHomePage = $account->getHomePage()->getValue();
     }
     if ($model instanceof Group) {
         $actor->type = 'group';
         $actor->members = array();
         foreach ($model->getMembers() as $agent) {
             $actor->members[] = Actor::fromModel($agent);
         }
     } else {
         $actor->type = 'agent';
     }
     return $actor;
 }
コード例 #2
0
ファイル: ActorTest.php プロジェクト: xabbuh/xapi-model
 /**
  * @dataProvider getActorsWithDifferingInverseFunctionalIdentifiers
  */
 public function testActorsDifferWhenInverseFunctionalIdentifierDiffer(Actor $actor1, Actor $actor2)
 {
     $this->assertFalse($actor1->equals($actor2));
 }
コード例 #3
0
 private static function fromActor(Actor $model)
 {
     $inverseFunctionalIdentifier = $model->getInverseFunctionalIdentifier();
     $object = new self();
     $object->mboxSha1Sum = $inverseFunctionalIdentifier->getMboxSha1Sum();
     $object->openId = $inverseFunctionalIdentifier->getOpenId();
     if (null !== ($mbox = $inverseFunctionalIdentifier->getMbox())) {
         $object->mbox = $mbox->getValue();
     }
     if (null !== ($account = $inverseFunctionalIdentifier->getAccount())) {
         $object->accountName = $account->getName();
         $object->accountHomePage = $account->getHomePage()->getValue();
     }
     if ($model instanceof Group) {
         $object->type = self::TYPE_GROUP;
         $object->members = array();
         foreach ($model->getMembers() as $agent) {
             $object->members[] = self::fromActor($agent);
         }
     } else {
         $object->type = self::TYPE_AGENT;
     }
     return $object;
 }
コード例 #4
0
 /**
  * @dataProvider deserializeData
  */
 public function testDeserializeActor($json, Actor $expectedActor)
 {
     $actor = $this->actorSerializer->deserializeActor($json);
     $this->assertInstanceOf('Xabbuh\\XApi\\Model\\Actor', $actor);
     $this->assertTrue($expectedActor->equals($actor), 'Deserialized actor has the expected properties');
 }