Passed
Pull Request — master (#1316)
by
unknown
37:37 queued 02:44
created

UserInfoResponse::generateHttpResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace League\OAuth2\Server\ResponseTypes;
4
5
use League\OAuth2\Server\Entities\ClaimSetInterface;
6
use Psr\Http\Message\ResponseInterface;
7
8
/**
9
 * A simple user info response for the ResourceServer class
10
 *
11
 * @author Marc Riemer <[email protected]>
12
 */
13
class UserInfoResponse extends AbstractResponseType
14
{
15
    public function __construct(
16
        protected ClaimSetInterface $claimSet
17
    ) {
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function generateHttpResponse(ResponseInterface $response)
24
    {
25
        $response = $response
26
            ->withStatus(200)
27
            ->withHeader('pragma', 'no-cache')
28
            ->withHeader('cache-control', 'no-store')
29
            ->withHeader('content-type', 'application/json; charset=UTF-8');
30
31
        $response->getBody()->write(\json_encode($this->claimSet->getClaims()));
32
33
        return $response;
34
    }
35
}
36