Completed
Push — master ( 41116d...43e4d4 )
by
unknown
13:57
created

ErrorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 90 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 36
loc 40
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUnsupportedMediaType() 18 18 1
A buildUnacceptable() 18 18 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
namespace RealPage\JsonApi;
4
5
use Neomerx\JsonApi\Document\Link;
6
use Neomerx\JsonApi\Document\Error;
7
use Neomerx\JsonApi\Contracts\Document\LinkInterface;
8
9
class ErrorFactory
10
{
11 View Code Duplication
    public static function buildUnsupportedMediaType(
0 ignored issues
show
Duplication introduced by
This method 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...
12
        $id = null,
13
        LinkInterface $aboutLink = null,
14
        $code = null,
15
        array $source = null,
16
        $meta = null
17
    ): Error {
18
        return new Error(
19
            $id ?? null,
20
            $aboutLink ?? new Link('http://jsonapi.org/format/#content-negotiation-clients'),
21
            '415',
22
            $code ?? null,
23
            'Unsupported Media Type',
24
            'Content-Type of a request containing JSON data must be application/vnd.api+json',
25
            $source,
26
            $meta
27
        );
28
    }
29
30 View Code Duplication
    public static function buildUnacceptable(
0 ignored issues
show
Duplication introduced by
This method 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...
31
        $id = null,
32
        LinkInterface $aboutLink = null,
33
        $code = null,
34
        array $source = null,
35
        $meta = null
36
    ): Error {
37
        return new Error(
38
            $id ?? null,
39
            $aboutLink ?? new Link('http://jsonapi.org/format/#content-negotiation-clients'),
40
            '406',
41
            $code ?? null,
42
            'Not Acceptable',
43
            'Accept header must accept application/vnd.api+json at least once without parameters',
44
            $source,
45
            $meta
46
        );
47
    }
48
}
49