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 ( 6122da...bfe9a2 )
by Freek
10:18 queued 11s
created

CsrfTokenReplacer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 80 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 24
loc 30
rs 10
c 0
b 0
f 0

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 Spatie\ResponseCache\Replacers;
4
5
use Symfony\Component\HttpFoundation\Response;
6
7
class CsrfTokenReplacer implements Replacer
8
{
9
    protected string $replacementString = '<laravel-responsecache-csrf-token-here>';
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
10
11
    public function prepareResponseToCache(Response $response): void
12
    {
13
        if (! $response->getContent()) {
14
            return;
15
        }
16
17
        $response->setContent(str_replace(
18
            csrf_token(),
19
            $this->replacementString,
20
            $response->getContent()
21
        ));
22
    }
23
24
    public function replaceInCachedResponse(Response $response): void
25
    {
26
        if (! $response->getContent()) {
27
            return;
28
        }
29
30
        $response->setContent(str_replace(
31
            $this->replacementString,
32
            csrf_token(),
33
            $response->getContent()
34
        ));
35
    }
36
}
37