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 — develop ( bc3c30...d86446 )
by Samuel
04:01
created

GetNearestPostOffice::buildRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
namespace LinusShops\CanadaPost\Services;
3
use Guzzle\Http\Client;
4
use LinusShops\CanadaPost\Service;
5
/**
6
 * Get the nearest post office
7
 *
8
 * @see https://www.canadapost.ca/cpo/mc/business/productsservices/developers/services/findpostoffice/nearestpostoffice.jsf
9
 * @author Sam Schmidt <[email protected]>
10
 * @since 2015-12-09
11
 * @company Linus Shops
12
 */
13
14
class GetNearestPostOffice extends Service
15
{
16
    private function getUri()
17
    {
18
        $uri = "/rs/postoffice?";
19
        if ($this->hasParameter('d2po')) {
20
            $uri .= "d2po={$this->getParameter('d2po')}";
21
        }
22
23
        if ($this->hasParameter('tonight')) {
24
            $uri .= "tonight={$this->getParameter('tonight')}";
25
        }
26
27
        $uri .= "maximum={$this->getParameter('maximum', 10)}";
28
29
        if ($this->hasParameter('longitude') && $this->hasParameter('latitude')) {
30
            $uri .= "logitude={$this->getParameter('longitude')}";
31
            $uri .= "latitude={$this->getParameter('latitude')}";
32
        } else {
33
            $uri .= "postalCode={$this->getParameter('postalCode')}";
34
            $uri .= "province={$this->getParameter('province')}";
35
            $uri .= "city={$this->getParameter('city')}";
36
            $uri .= "streetName={$this->getParameter('streetName')}";
37
        }
38
39
        return $uri;
40
    }
41
42
    /**
43
     * @return \Guzzle\Http\Message\RequestInterface
44
     */
45
    protected function buildRequest()
46
    {
47
        $client = new Client($this->getBaseUrl());
48
        $request = $client->get($this->getUri());
49
        $request
50
            ->addHeader('Accept', 'application/vnd.cpc.postoffice+xml ');
51
        return $request;
52
    }
53
}
54