LinkedDataResource::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 6

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 13
rs 9.9666
cc 2
nc 6
nop 1
1
<?php
2
3
class LinkedDataResource extends RemoteResource
4
{
5
    public function resolve(int $timeout): ?EasyRdf\Resource
6
    {
7
        try {
8
            // change the timeout setting for external requests
9
            $httpclient = EasyRdf\Http::getDefaultHttpClient();
10
            $httpclient->setConfig(array('timeout' => $timeout, 'useragent' => 'Skosmos'));
11
            EasyRdf\Http::setDefaultHttpClient($httpclient);
12
13
            $graph = EasyRdf\Graph::newAndLoad(EasyRdf\Utils::removeFragmentFromUri($this->uri));
14
            return $graph->resource($this->uri);
15
        } catch (Exception $e) {
16
            $this->model->getLogger()->info("LD resolution failed for <{$this->uri}>: $e");
17
            return null;
18
        }
19
20
    }
21
22
}
23