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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 6
c 5
b 0
f 1
lcom 1
cbo 1
dl 0
loc 40
ccs 0
cts 29
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getUri() 0 25 5
A buildRequest() 0 8 1
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