Passed
Pull Request — master (#43)
by Mostafa Abd El-Salam
04:46
created

UnauthorizedException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 51.85 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 14
loc 27
ccs 4
cts 6
cp 0.6667
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 2

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 Maklad\Permission\Exceptions;
4
5
use http\Exception;
6
use Symfony\Component\HttpKernel\Exception\HttpException;
7
8
/**
9
 * Class UnauthorizedException
10
 * @package Maklad\Permission\Exceptions
11
 */
12
class UnauthorizedException extends HttpException
13
{
14
15
    /**
16
     * UnauthorizedException constructor.
17
     *
18
     * @param $statusCode
19
     * @param null $message
20
     * @param Exception $previous
21
     * @param array $headers
22
     * @param int $code
23
     */
24 7 View Code Duplication
    public function __construct(
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...
25
        $statusCode,
26
        $message = null,
27
        Exception $previous = null,
28
        array $headers = array(),
29
        $code = 0
30
    ) {
31 7
        parent::__construct($statusCode, $message, $previous, $headers, $code);
32
33 7
        if (\config('permission.log_registration_exception')) {
34
            $logger = \app('log');
35
            $logger->alert($message);
36
        }
37 7
    }
38
}
39