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

ExpectationFailed   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getStatus() 4 4 1
A getType() 4 4 1
A getFailedExpectations() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\ApiProblem\ClientError;
6
7
use Chubbyphp\ApiHttp\ApiProblem\AbstractApiProblem;
8
9 View Code Duplication
final class ExpectationFailed extends AbstractApiProblem
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @var string[]
13
     */
14
    private $failedExpectations = [];
15
16
    /**
17
     * @param string[]    $failedExpectations
18
     * @param string      $title
19
     * @param string|null $detail
20
     * @param string|null $instance
21
     */
22 2
    public function __construct(array $failedExpectations, string $title, string $detail = null, string $instance = null)
23
    {
24 2
        parent::__construct($title, $detail, $instance);
25
26 2
        $this->failedExpectations = $failedExpectations;
27 2
    }
28
29
    /**
30
     * @return int
31
     */
32 2
    public function getStatus(): int
33
    {
34 2
        return 417;
35
    }
36
37
    /**
38
     * @return string
39
     */
40 2
    public function getType(): string
41
    {
42 2
        return 'https://tools.ietf.org/html/rfc2616#section-10.4.18';
43
    }
44
45
    /**
46
     * @return string[]
47
     */
48 2
    public function getFailedExpectations(): array
49
    {
50 2
        return $this->failedExpectations;
51
    }
52
}
53