Passed
Pull Request — master (#2)
by Dominik
02:16
created

PaymentRequired   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatus() 0 4 1
A getType() 0 4 1
A withPaymentTypes() 0 7 1
A getPaymentTypes() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\ApiProblem\ClientError;
6
7
use Chubbyphp\ApiHttp\ApiProblem\AbstractApiProblem;
8
use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface;
9
10
final class PaymentRequired extends AbstractApiProblem
11
{
12
    /**
13
     * @var string[]
14
     */
15
    private $paymentTypes = [];
16
17
    /**
18
     * @return int
19
     */
20 2
    public function getStatus(): int
21
    {
22 2
        return 402;
23
    }
24
25
    /**
26
     * @return string
27
     */
28 2
    public function getType(): string
29
    {
30 2
        return 'https://tools.ietf.org/html/rfc2616#section-10.4.3';
31
    }
32
33
    /**
34
     * @param array $paymentTypes
35
     *
36
     * @return ApiProblemInterface
37
     */
38 1
    public function withPaymentTypes(array $paymentTypes): ApiProblemInterface
39
    {
40 1
        $clone = clone $this;
41 1
        $clone->paymentTypes = $paymentTypes;
42
43 1
        return $clone;
44
    }
45
46
    /**
47
     * @return string[]
48
     */
49 2
    public function getPaymentTypes(): array
50
    {
51 2
        return $this->paymentTypes;
52
    }
53
}
54