addType('resourceId','integer'); $this->addType('permissionLevel','integer'); $this->addType('type','integer'); $this->addType('createdTimestamp','integer'); $this->addType('lastUpdatedTimestamp','integer'); } public function jsonSerialize(): array { return [ 'id' => $this->id, 'resourceId' => $this->resourceId, 'permissionLevel' => $this->permissionLevel, 'type' => $this->type, 'principal' => $this->principal, 'createdTimestamp' => $this->createdTimestamp, 'lastUpdatedTimestamp' => $this->lastUpdatedTimestamp, ]; } public function tableSerialize(?array $params = null): array { return [ 'Id' => $this->id, 'Resource Id' => $this->resourceId, 'Permission Level' => MemberPermissionLevel::from($this->permissionLevel)->name, 'Type' => MemberType::from($this->type)->name, 'Principal' => $this->principal, 'Created' => $this->createdTimestamp, 'LastUpdated' => $this->lastUpdatedTimestamp, ]; } public function getParsedPrincipal() { if($this->type === MemberType::USER->value) { return [ "userId" => $this->principal, ]; } else if($this->type === MemberType::GROUP->value) { return [ "groupId" => $this->principal, ]; } else if($this->type === MemberType::ROLE->value) { [$organizationProviderId, $roleId] = explode(":", $this->principal, 2); return [ "organizationProviderId" => $organizationProviderId, "roleId" => $roleId, ]; } } }