id; } /** * Get string representation. * * @return string Returns the json_encode of this object * * @since 1.0.0 */ public function __toString() : string { return (string) \json_encode($this->toArray()); } /** * {@inheritdoc} */ public function toArray() : array { return [ 'id' => $this->id, 'name' => $this->name, 'description' => $this->description, 'permissions' => $this->permissions, 'members' => $this->members, 'parents' => $this->parents, 'status' => $this->status, ]; } /** * Json serialize. * * @return array * * @since 1.0.0 */ /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } /** * Create object from array * * @param array{id:int, name:string, description:string, members:array, parents:array, status:int, permissions?:array} $group Group data * * @return self * * @since 1.0.0 */ public static function fromJson(array $group) : self { $new = new self(); $new->id = $group['id']; $new->name = $group['name']; $new->description = $group['description']; $new->members = $group['members']; $new->parents = $group['parents']; $new->status = $group['status']; foreach (($group['permissions'] ?? []) as $permission) { $new->permissions[] = PermissionAbstract::fromJson($permission); } return $new; } }