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 ( b0e03a...4af0c2 )
by Tobias
02:50
created

LoggerPlugin::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Plugin\Plugin;
14
15
use Geocoder\Collection;
16
use Geocoder\Exception\Exception;
17
use Geocoder\Query\Query;
18
use Psr\Log\LoggerInterface;
19
20
/**
21
 * Log all queries and the result/failure
22
 *
23
 * @author Tobias Nyholm <[email protected]>
24
 */
25
class LoggerPlugin
26
{
27
    /**
28
     * @var LoggerInterface
29
     */
30
    private $logger;
31
32
    /**
33
     * @param LoggerInterface $logger
34
     */
35
    public function __construct(LoggerInterface $logger)
36
    {
37
        $this->logger = $logger;
38
    }
39
40
    public function handleQuery(Query $query, callable $next, callable $first)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
Unused Code introduced by
The parameter $first is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        $startTime = microtime(true);
43
        $logger = $this->logger;
44
45
        return $next($query)->then(function (Collection $result) use ($logger, $query, $startTime) {
46
            $duration = (microtime(true) - $startTime) * 1000;
47
            $this->logger->info(sprintf('[Geocoder] Got %d results in %0.2f ms for query %s', count($result), $duration, $query->__toString()));
48
49
            return $result;
50
        }, function (Exception $exception) use ($logger, $query, $startTime) {
51
            $duration = (microtime(true) - $startTime) * 1000;
52
            $this->logger->error(sprintf('[Geocoder] Failed with %s after %0.2f ms for query %s', get_class($exception), $duration, $query->__toString()));
53
54
            throw $exception;
55
        });
56
    }
57
}
58