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

QueryDataPlugin::handleQuery()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 3
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\Plugin\Plugin;
16
use Geocoder\Query\Query;
17
18
/**
19
 * Add arbitrary data to a query
20
 *
21
 * @author Tobias Nyholm <[email protected]>
22
 */
23
class QueryDataPlugin implements Plugin
24
{
25
    /**
26
     * @var array
27
     */
28
    private $data;
29
30
    /**
31
     * @var bool
32
     */
33
    private $force;
34
35
    /**
36
     * @param array $data
37
     * @param bool  $force If true we overwrite existing values
38
     */
39
    public function __construct(array $data, $force = false)
40
    {
41
        $this->data = $data;
42
        $this->force = $force;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function handleQuery(Query $query, callable $next, callable $first)
49
    {
50
        $queryData = $query->getAllData();
51
        foreach ($this->data as $key => $value) {
52
            if ($this->force || !array_key_exists($key, $queryData)) {
53
                $query = $query->withData($key, $value);
54
            }
55
        }
56
57
        return $next($query);
58
    }
59
}
60