public function resolve(Context $context) { if (f\not($context->getScopes()->isEmpty())) { return $context; } $defaultScopes = ScopeCollection::createFromString(f\get($context->getClient(), 'defaultScope')); return new Context($context->getClient(), $context->getUserId(), $defaultScopes); }
public function testContext() { $client = $this->createClient(); $userId = 'foo'; $scopes = new ScopeCollection([new Scope('foo')]); $context = new Context($client, $userId, $scopes); $this->assertSame($client, $context->getClient()); $this->assertSame($userId, $context->getUserId()); $this->assertSame($scopes, $context->getScopes()); }
public function create(Context $context) { return new AccessToken(['token' => $this->tokenGenerator->generate(), 'type' => 'bearer', 'clientId' => f\get($context->getClient(), 'id'), 'userId' => $context->getUserId(), 'lifetime' => $this->lifetime, 'scope' => $context->getScopes()->__toString()]); }