*/ final readonly class GuildMentionsQuery { public function __construct(private Features $features, private Hashtags $hashtags, private GuildsQuery $guilds) { // } /** * @param iterable $texts * @return array */ public function get(iterable $texts, ?User $viewer): array { if (! $viewer instanceof User) { return []; } $handles = array_values(collect($texts)->flatMap($this->hashtags->handles(...))->unique()->all()); if ($handles === [] || ! $this->features->available(Feature::Guilds, $viewer)) { return []; } return $this->guilds->references($handles)->keyBy(fn (Guild $guild): string => mb_strtolower($guild->handle))->all(); } }