GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#18)
by
unknown
11:41
created

ValidationException   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A handleJson() 0 12 3
A handleString() 0 12 3
1
<?php namespace Vindi\Exceptions;
2
3
class ValidationException extends RequestException
4
{
5
    /**
6
     * ValidationException constructor.
7
     *
8
     * @param int $status
9
     * @param mixed $errors
10
     * @param array $lastOptions
11 4
     */
12
    public function __construct($status, $errors, array $lastOptions = [])
13 4
    {
14
        parent::__construct($status, $errors, $lastOptions);
15 4
16 4
        $this->message = env('VINDI_EXCEPTION_AS_JSON', false) ? $this->handleJson($errors) : $this->handleString($errors);
17
    }
18
19
    /**
20
     * Handle errors response as json
21
     *
22
     * @param $errors
23
     * @return string
24
     */
25
    public function handleJson($errors)
26
    {
27
        $error_log = [];
28
29
        if (is_string($errors))
30
            return $errors;
31
32
        foreach ($errors as $error)
33
            $error_log[$error->parameter] = $error->message;
34
35
        return json_encode($error_log);
36
    }
37
38
    /**
39
     * Handle errors response as string
40
     *
41
     * @param $errors
42
     * @return string
43
     */
44
    public function handleString($errors)
45
    {
46
        $error_log = '';
47
48
        if (is_string($errors))
49
            return $errors;
50
51
        foreach ($errors as $error)
52
            $error_log .= "\n[{$error->parameter}] {$error->message}";
53
54
        return "Os seguintes erros de validação foram encontrados:" . $error_log;
55
    }
56
}
57