SerializerException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 27
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unableToNormalizePayload() 12 12 1
A badRequest() 11 11 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 As3\Modlr\Api;
4
5
use As3\Modlr\Exception\AbstractHttpException;
6
7
/**
8
 * Serializer exceptions.
9
 *
10
 * @author Jacob Bare <[email protected]>
11
 */
12 View Code Duplication
class SerializerException extends AbstractHttpException
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...
13
{
14
    public static function unableToNormalizePayload($type, $message = null)
15
    {
16
        return new self(
17
            sprintf(
18
                'Unable to normalize payload for entity type "%s". %s',
19
                $type,
20
                $message
21
            ),
22
            400,
23
            __FUNCTION__
24
        );
25
    }
26
27
    public static function badRequest($message = null)
28
    {
29
        return new self(
30
            sprintf(
31
                'Oops. We were unable to process this API request. %s',
32
                $message
33
            ),
34
            400,
35
            __FUNCTION__
36
        );
37
    }
38
}
39