Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add RequiresScope attribute for declaring scope requirements

+37
+37
src/Attributes/RequiresScope.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Attributes; 4 + 5 + use Attribute; 6 + use SocialDept\AtpClient\Enums\Scope; 7 + 8 + #[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] 9 + class RequiresScope 10 + { 11 + public array $scopes; 12 + 13 + /** 14 + * @param string|Scope|array<string|Scope> $scopes Required scope(s) for this method 15 + * @param string|null $granular Future granular scope equivalent 16 + * @param string $description Human-readable description of scope requirement 17 + */ 18 + public function __construct( 19 + string|Scope|array $scopes, 20 + public readonly ?string $granular = null, 21 + public readonly string $description = '', 22 + ) { 23 + $this->scopes = $this->normalizeScopes($scopes); 24 + } 25 + 26 + protected function normalizeScopes(string|Scope|array $scopes): array 27 + { 28 + if (! is_array($scopes)) { 29 + $scopes = [$scopes]; 30 + } 31 + 32 + return array_map( 33 + fn ($scope) => $scope instanceof Scope ? $scope->value : $scope, 34 + $scopes 35 + ); 36 + } 37 + }