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.

DebugExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 3
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 7 1
A dump() 0 11 1
A getName() 0 3 1
1
<?php
2
3
namespace EightPoints\Bundle\GuzzleBundle\Twig\Extension;
4
5
use Symfony\Component\VarDumper\Cloner\VarCloner;
6
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
7
use Twig\Environment;
8
use Twig\Extension\AbstractExtension;
9
use Twig\TwigFunction;
10
11
class DebugExtension extends AbstractExtension
12
{
13
    /**
14
     * @return array
15
     */
16
    public function getFunctions() : array
17
    {
18
        return [
19
            new TwigFunction(
20
                'eight_points_guzzle_dump',
21
                [$this, 'dump'],
22
                ['is_safe' => ['html'], 'needs_environment' => true]
23
            ),
24
        ];
25
    }
26
27
    /**
28
     * @param Environment $env
29
     * @param $value
30
     *
31
     * @throws \Exception
32
     *
33
     * @return bool|string
34
     */
35
    public function dump(Environment $env, $value)
36
    {
37
        $cloner = new VarCloner();
38
39
        $dump = fopen('php://memory', 'r+b');
40
        $dumper = new HtmlDumper($dump, $env->getCharset());
41
42
        $dumper->dump($cloner->cloneVar($value));
43
        rewind($dump);
0 ignored issues
show
Bug introduced by
It seems like $dump can also be of type false; however, parameter $handle of rewind() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
        rewind(/** @scrutinizer ignore-type */ $dump);
Loading history...
44
45
        return stream_get_contents($dump);
0 ignored issues
show
Bug introduced by
It seems like $dump can also be of type false; however, parameter $handle of stream_get_contents() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
        return stream_get_contents(/** @scrutinizer ignore-type */ $dump);
Loading history...
46
    }
47
48
    /**
49
     * This method is removed from interface in Twig v2.0
50
     *
51
     * @TODO Remove this method when drop support of Symfony < 5.0
52
     *
53
     * @return string
54
     */
55
    public function getName() : string
56
    {
57
        return get_class($this);
58
    }
59
}
60