Passed
Pull Request — master (#195)
by
unknown
08:13
created

RorDataService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 25
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrganisationData() 0 5 1
A __construct() 0 1 1
A searchTermReplacement() 0 2 1
A searchOrganisationRequest() 0 5 1
1
<?php
2
namespace EWW\Dpf\Services\FeUser;
3
4
use \Httpful\Request;
5
6
class RorDataService
7
{
8
9
    protected $apiUrl = 'https://api.ror.org/organizations';
10
11
    public function __construct() {
12
13
    }
14
15
    public function searchTermReplacement($searchTerm) {
16
        return urlencode($searchTerm);
17
    }
18
19
    public function searchOrganisationRequest($searchTerm) {
20
        $response = Request::get($this->apiUrl . '?query=' . $this->searchTermReplacement($searchTerm))
21
            ->send();
22
23
        return ['entries' => $response->body->items];
24
    }
25
26
    public function getOrganisationData($rorId) {
27
        $response = Request::get($this->apiUrl . '/' . $rorId)
28
            ->send();
29
30
        return $response->body;
31
    }
32
33
}