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 — place-services ( 94b48b...a9c14c )
by Eric
67:56 queued 04:38
created

AbstractService::getMessageFactory()   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 0
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service;
13
14
use Http\Client\HttpClient;
15
use Http\Message\MessageFactory;
16
use Psr\Http\Message\RequestInterface as PsrRequestInterface;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
abstract class AbstractService
22
{
23
    /**
24
     * @var string
25
     */
26
    private $url;
27
28
    /**
29
     * @var string|null
30
     */
31
    private $key;
32
33
    /**
34
     * @var BusinessAccount|null
35
     */
36
    private $businessAccount;
37
38
    /**
39
     * @param string $url
40
     */
41
    public function __construct($url)
42
    {
43
        $this->setUrl($url);
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getUrl()
50
    {
51
        return $this->url;
52
    }
53
54
    /**
55
     * @param string $url
56
     */
57
    public function setUrl($url)
58
    {
59
        $this->url = $url;
60
    }
61
62
    /**
63
     * @return bool
64
     */
65
    public function hasKey()
66
    {
67
        return $this->key !== null;
68
    }
69
70
    /**
71
     * @return string|null
72
     */
73
    public function getKey()
74
    {
75
        return $this->key;
76
    }
77
78
    /**
79
     * @param string|null $key
80
     */
81
    public function setKey($key)
82
    {
83
        $this->key = $key;
84
    }
85
86
    /**
87
     * @return bool
88
     */
89
    public function hasBusinessAccount()
90
    {
91
        return $this->businessAccount !== null;
92
    }
93
94
    /**
95
     * @return BusinessAccount
96
     */
97
    public function getBusinessAccount()
98
    {
99
        return $this->businessAccount;
100
    }
101
102
    /**
103
     * @param BusinessAccount $businessAccount
104
     */
105
    public function setBusinessAccount(BusinessAccount $businessAccount = null)
106
    {
107
        $this->businessAccount = $businessAccount;
108
    }
109
110
    /**
111
     * @param RequestInterface $request
112
     *
113
     * @return string
114
     */
115
    protected function createUrl(RequestInterface $request)
116
    {
117
        $query = $request->buildQuery();
118
119
        if ($this->hasKey()) {
120
            $query['key'] = $this->key;
121
        }
122
123
        $url = $this->createBaseUrl($request).'?'.http_build_query($query, '', '&');
124
125
        if ($this->hasBusinessAccount()) {
126
            $url = $this->businessAccount->signUrl($url);
127
        }
128
129
        return $url;
130
    }
131
132
    /**
133
     * @param RequestInterface $request
134
     *
135
     * @return string
136
     */
137
    protected function createBaseUrl(RequestInterface $request)
138
    {
139
        $url = $this->getUrl();
140
141
        if ($request instanceof ContextualizedRequestInterface) {
142
            $url .= '/'.$request->buildContext();
143
        }
144
145
        return $url;
146
    }
147
}
148