Something went wrong. Try again.
Laravel AT Protocol Client (alpha & unstable)
Something went wrong. Try again.
2.0 kB · 74 lines
PHP
at dev
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475<?php
namespace SocialDept\AtpClient\Enums;
use BackedEnum;
enum Scope: string{ // Transition scopes (current) case Atproto = 'atproto'; case TransitionGeneric = 'transition:generic'; case TransitionEmail = 'transition:email'; case TransitionChat = 'transition:chat.bsky';
/** * Build a repo scope string for record operations. * * @param string|BackedEnum $collection The collection NSID (e.g., 'app.bsky.feed.post') * @param array|null $actions The action (create, update, delete) * * @return string */ public static function repo(string|BackedEnum $collection, ?array $actions = []): string { $collection = $collection instanceof BackedEnum ? $collection->value : $collection; $scope = "repo:{$collection}";
if (!empty($actions)) { $scope .= '?' . implode('&', array_map(fn ($action) => "action={$action}", $actions)); }
return $scope; }
/** * Build an RPC scope string for endpoint access. * * @param string $lxm The lexicon method ID (e.g., 'app.bsky.feed.getTimeline') */ public static function rpc(string $lxm): string { return "rpc:{$lxm}"; }
/** * Build a blob scope string for uploads. * * @param string|null $mimeType The mime type pattern (e.g., 'image/*', '*\/*') */ public static function blob(?string $mimeType = null): string { return 'blob:'.($mimeType ?? '*/*'); }
/** * Build an account scope string. * * @param string $attr The account attribute (e.g., 'email', 'status') */ public static function account(string $attr): string { return "account:{$attr}"; }
/** * Build an identity scope string. * * @param string $attr The identity attribute (e.g., 'handle') */ public static function identity(string $attr): string { return "identity:{$attr}"; }}