Completed
Pull Request — master (#2)
by Dominik
04:37
created

UnauthorizedApiProblem::getStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\ApiProblem;
6
7
final class UnauthorizedApiProblem extends ApiProblem
8
{
9
    /**
10
     * @var string[]
11
     */
12
    private $authorizationTypes = [];
13
14
    /**
15
     * @return int
16
     */
17 2
    public function getStatus(): int
18
    {
19 2
        return 401;
20
    }
21
22
    /**
23
     * @return string
24
     */
25 2
    public function getType(): string
26
    {
27 2
        return 'https://tools.ietf.org/html/rfc2616#section-10.4.2';
28
    }
29
30
    /**
31
     * @param array $authorizationTypes
32
     *
33
     * @return ApiProblemInterface
34
     */
35 1
    public function withAuthorizationTypes(array $authorizationTypes): ApiProblemInterface
36
    {
37 1
        $clone = clone $this;
38 1
        $clone->authorizationTypes = $authorizationTypes;
39
40 1
        return $clone;
41
    }
42
43
    /**
44
     * @return string[]
45
     */
46 2
    public function getAuthorizationTypes(): array
47
    {
48 2
        return $this->authorizationTypes;
49
    }
50
}
51