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
Push — master ( 5fd32e...bbf340 )
by James
01:52
created

ErrorBag   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 39
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createErrorBagForMessage() 0 6 1
A getErrorBagForStatusCode() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PragmaRX\Google2FALaravel\Support;
6
7
use Illuminate\Support\MessageBag;
8
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
9
10
/**
11
 * Trait ErrorBag
12
 */
13
trait ErrorBag
14
{
15
    /**
16
     * Create an error bag and store a message on int.
17
     *
18
     * @param $message
19
     *
20
     * @return MessageBag
21
     */
22 3
    protected function createErrorBagForMessage($message)
23
    {
24 3
        return new MessageBag([
25 3
            'message' => $message,
26
        ]);
27
    }
28
29
    /**
30
     * Get a message bag with a message for a particular status code.
31
     *
32
     * @param $statusCode
33
     *
34
     * @return MessageBag
35
     */
36 3
    protected function getErrorBagForStatusCode($statusCode)
37
    {
38
        $errorMap = [
39 3
            SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY => 'google2fa.error_messages.wrong_otp',
40 3
            SymfonyResponse::HTTP_BAD_REQUEST          => 'google2fa.error_messages.cannot_be_empty',
41
        ];
42
43 3
        return $this->createErrorBagForMessage(
44 3
            trans(
45 3
                config(
46 3
                    array_key_exists($statusCode, $errorMap) ? $errorMap[$statusCode] : 'google2fa.error_messages.unknown'
47
                )
48
            )
49
        );
50
    }
51
}
52