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 ( c4a10f...5fd32e )
by James
01:57
created

ErrorBag::getErrorBagForStatusCode()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 7
cp 0
rs 9.7666
c 0
b 0
f 0
cc 2
nc 1
nop 1
crap 6
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
    protected function createErrorBagForMessage($message)
23
    {
24
        return new MessageBag([
25
            '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
    protected function getErrorBagForStatusCode($statusCode)
37
    {
38
        $errorMap = [
39
            SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY => 'google2fa.error_messages.wrong_otp',
40
            SymfonyResponse::HTTP_BAD_REQUEST          => 'google2fa.error_messages.cannot_be_empty',
41
        ];
42
43
        return $this->createErrorBagForMessage(
44
            trans(
45
                config(
46
                    array_key_exists($statusCode, $errorMap) ? $errorMap[$statusCode] : 'google2fa.error_messages.unknown'
47
                )
48
            )
49
        );
50
    }
51
}
52