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 ( 38ea04...fb6180 )
by Bill
02:29
created

EnrichmentApi   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 73.08%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 52
ccs 19
cts 26
cp 0.7308
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A combined() 0 5 1
A person() 0 10 2
A flagPerson() 0 5 1
A company() 0 5 1
A flagCompany() 0 5 1
A composeUrl() 0 5 2
1
<?php
2
3
namespace wlbrough\clearbit;
4
5
use wlbrough\clearbit\Abstracts\Api;
6
7
class EnrichmentApi extends Api
8
{
9
    private static $apiUrlTemplate = 'https://pk:@%s%s.clearbit.com/v2/%s/find?%s=%s';
10
    private $httpClient = null;
11
12 24
    public function __construct($key, $client = null)
13
    {
14 24
        self::$apiUrlTemplate = preg_replace('(pk)', $key, self::$apiUrlTemplate);
15 24
        $this->httpClient = $client;
16 24
    }
17
18 6
    public function combined($email)
19
    {
20 6
        $apiUrl = $this->composeUrl('person', 'combined', 'email', $email);
21 6
        return $this->call($apiUrl, $this->httpClient);
22
    }
23
24 6
    public function person($email, $subscribe = false)
25
    {
26 6
        $apiUrl = $this->composeUrl('person', 'people', 'email', $email);
27
28 6
        if ($subscribe) {
29
            $apiUrl .= '&subscribe=true';
30
        }
31
32 6
        return $this->call($apiUrl, $this->httpClient);
33
    }
34
35
    public function flagPerson($personId, $corrected = null)
36
    {
37
        $apiUrl = "https://person.clearbit.com/v1/people/$personId/flag";
38
        return $this->post($apiUrl, $corrected, 200, $this->httpClient);
39
    }
40
41 6
    public function company($domain)
42
    {
43 6
        $apiUrl = $this->composeUrl('company', 'companies', 'domain', $domain);
44 6
        return $this->call($apiUrl, $this->httpClient);
45
    }
46
47 3
    public function flagCompany($domain, $corrected = null)
48
    {
49
        $apiUrl = "https://company.clearbit.com/v2/companies/flag?domain=$domain";
50
        return $this->post($apiUrl, $corrected, 200, $this->httpClient);
51 3
    }
52
53 18
    private function composeUrl($subdomain, $path, $query, $parameter)
54
    {
55 18
        $streaming = $this->useStreaming ? '' : '-streaming';
56 18
        return sprintf(self::$apiUrlTemplate, $subdomain, $streaming, $path, $query, $parameter);
57
    }
58
}
59