getAgentIdentifier() 정적인 공개 메소드

Determines which identifier is currently in use in the given actor.
static public getAgentIdentifier ( stdClass $actor ) : String | null
$actor stdClass
리턴 String | null Identifier in use.
예제 #1
0
 /**
  * Removes properties other than `objectType` and identifier from objects inside a statement.
  * @param \stdClass $statement Statement to be formatted.
  * @return \stdClass Formatted statement.
  */
 public function identityStatement(\stdClass $statement)
 {
     $actor = $statement->actor;
     // Processes an anonymous group or actor.
     $is_anonymous_group = $actor->objectType === 'Group' && Helpers::getAgentIdentifier($actor) === null;
     if ($is_anonymous_group) {
         $actor->members = array_map(function (\stdClass $member) {
             return $this->identityObject($member, Helpers::getAgentIdentifier($member));
         }, $actor->members);
     } else {
         $actor = $this->identityObject($actor, Helpers::getAgentIdentifier($actor));
     }
     // Replace parts of the statements.
     $statement->actor = $actor;
     $statement->object = $this->identityObject($statement->object, Helpers::getAgentIdentifier($statement->object) ?: 'id');
     return $statement;
 }
 /**
  * Constructs a builder using the given agent and options.
  * @param \stdClass $agent Agent to be matched.
  * @param Builder $builder
  * @param IndexOptions $opts Index options.
  * @return Builder
  */
 private function matchAgent(\stdClass $agent, Builder $builder, IndexOptions $opts)
 {
     $id_key = Helpers::getAgentIdentifier($agent);
     if ($id_key === 'account') {
         $builder = $this->matchAgentProp('account.homePage', $agent->account->homePage, $builder, $opts);
         $builder = $this->matchAgentProp('account.name', $agent->account->name, $builder, $opts);
     } else {
         $builder = $this->matchAgentProp($id_key, $agent->{$id_key}, $builder, $opts);
     }
     return $builder;
 }