SnifferErrorResponse   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 42.86 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 9
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 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 SnifferReport\Response;
4
5
use Symfony\Component\HttpFoundation\JsonResponse;
6
7
class SnifferErrorResponse extends JsonResponse
8
{
9
10
    /**
11
     * SnifferErrorResponse constructor.
12
     *
13
     * Defines a standard way of returning an error response in the app.
14
     *
15
     * @param string $message
16
     * @param int $code
17
     */
18 View Code Duplication
    public function __construct($message, $code = 500)
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...
19
    {
20
        $data = [
21
            'status' => 'error',
22
            'code' => $code,
23
            'message' => $message,
24
        ];
25
        parent::__construct(json_encode($data), $code, [], true);
26
    }
27
}
28