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.

ProfileMiddleware::profile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 24
rs 9.8333
1
<?php
2
3
namespace EightPoints\Bundle\GuzzleBundle\Middleware;
4
5
use Symfony\Component\Stopwatch\Stopwatch;
6
7
/**
8
 * This Middleware is used to render request time slot on "Performance" tab in "Symfony Profiler".
9
 */
10
class ProfileMiddleware
11
{
12
    /**
13
     * @var \Symfony\Component\Stopwatch\Stopwatch
14
     */
15
    private $stopwatch;
16
17
    /**
18
     * @param \Symfony\Component\Stopwatch\Stopwatch $stopwatch
19
     */
20
    public function __construct(Stopwatch $stopwatch)
21
    {
22
        $this->stopwatch = $stopwatch;
23
    }
24
25
    /**
26
     * Profiling each Request
27
     *
28
     * @return \Closure
29
     */
30
    public function profile() : \Closure
31
    {
32
        $stopwatch = $this->stopwatch;
33
34
        return function (callable $handler) use ($stopwatch) {
35
36
            return function ($request, array $options) use ($handler, $stopwatch) {
37
                $event = $stopwatch->start(
38
                    sprintf('%s %s', $request->getMethod(), $request->getUri()),
39
                    'eight_points_guzzle'
40
                );
41
42
                return $handler($request, $options)->then(
43
44
                    function ($response) use ($event) {
45
                        $event->stop();
46
47
                        return $response;
48
                    },
49
50
                    function ($reason) use ($event) {
51
                        $event->stop();
52
53
                        return \GuzzleHttp\Promise\rejection_for($reason);
54
                    }
55
                );
56
            };
57
        };
58
    }
59
}
60